Skip to content

Commit

Permalink
Preload.php Generator: Data Object / Field Collection / Object Bricks…
Browse files Browse the repository at this point in the history
… class files - see #5387
  • Loading branch information
brusch committed Feb 16, 2021
1 parent 174e3b8 commit f46984b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bundles/CoreBundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ services:
tags:
- { name: kernel.cache_warmer }

Pimcore\HttpKernel\CacheWarmer\PimcoreCoreCacheWarmer:
public: false
tags:
- { name: kernel.cache_warmer }

Pimcore\Cache\Symfony\CacheClearer:
public: true

Expand Down
72 changes: 72 additions & 0 deletions lib/HttpKernel/CacheWarmer/PimcoreCoreCacheWarmer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Enterprise License (PEL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PEL
*/

namespace Pimcore\HttpKernel\CacheWarmer;

use Pimcore\Model\DataObject;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;

class PimcoreCoreCacheWarmer implements CacheWarmerInterface
{

/**
* @inheritDoc
*/
public function isOptional()
{
return true;
}

/**
* @inheritDoc
*/
public function warmUp($cacheDir)
{
$classes = [];

// load all data object classes
$list = new DataObject\ClassDefinition\Listing();
$list = $list->load();

foreach ($list as $classDefinition) {
$className = DataObject::class . '\\' . ucfirst($classDefinition->getName());
$listingClass = $className . '\\Listing';

$classes[] = $className;
$classes[] = $listingClass;
}


$list = new DataObject\Objectbrick\Definition\Listing();
$list = $list->load();

foreach ($list as $brickDefinition) {
$className = 'Pimcore\\Model\\DataObject\\Objectbrick\\Data' . ucfirst($brickDefinition->getKey());

$classes[] = $className;
}

$list = new DataObject\Fieldcollection\Definition\Listing();
$list = $list->load();

foreach ($list as $fcDefinition) {
$className = 'Pimcore\\Model\\DataObject\\Fieldcollection\\Data' . ucfirst($fcDefinition->getKey());

$classes[] = $className;
}


return $classes;
}
}

0 comments on commit f46984b

Please sign in to comment.