Load and initialize the preview model.

@return \Smile\ElasticsuiteVirtualCategory\Model\Preview
336023
private function getPreviewObject()
    {
        $category = $this->getCategory();
        $pageSize = $this->getPageSize();
        $search = $this->getRequest()->getParam('search');

        return $this->previewModelFactory->create(['category' => $category, 'size' => $pageSize, 'search' => $search]);
    }
509116
public function init() {		
		\frenzelgmbh\cmcategories\categoriesAsset::register(\Yii::$app->view);
		return parent::init();
	}
458792
public function renderPreview() {
        $previewFieldMap=array(
                                'ClassName'=>$this->DestinationClass,
                                'IsKapostPreview'=>true,
                                'Children'=>false,
                                'Menu'=>false,
                                'MetaTags'=>false,
                                'Breadcrumbs'=>false,
                                'current_stage'=>Versioned::current_stage(),
                                'SilverStripeNavigator'=>false
                            );
        
        //Allow extensions to add onto the array
        $extensions=$this->extend('updatePreviewFieldMap');
        $extensions=array_filter($extensions, function($v) {return !is_null($v) && is_array($v);});
        if(count($extensions)>0) {
            foreach($extensions as $ext) {
                $previewFieldMap=array_merge($previewFieldMap, $ext);
            }
        }
        
        
        //Find the controller class
        $ancestry=ClassInfo::ancestry($this->DestinationClass);
        while($class=array_pop($ancestry)) {
            if(class_exists($class."_Controller")) {
                break;
            }
        }
        
        $controller=($class!==null ? "{$class}_Controller":"ContentController");
        
        return $controller::create($this)->customise($previewFieldMap);
    }
328928
protected function Init()
    {
        $contentContainer = ContentContainer::Schema()->ByContent($this->content);
        $tree = new ContainerContentTreeProvider($contentContainer->GetContainer());
        
        $renderer = new ContentsRenderer($tree->TopMost(), $tree);
        $this->contents = $renderer->Render();
        return parent::Init();
    }
1215912
private function load()
    {
        // Get English version
        $english = $this->getTranslations(__DIR__, 'en');
        $languages = $this->getLanguages();

        $this->compareTranslations($english, $languages);
    }
751086
protected static function initialize() {
		$loader = new \Twig_Loader_Filesystem();

		foreach(Modules::getAll() as $module)
			if(file_exists($module->getPath() . '/Views'))
				$loader->addPath($module->getPath() . '/Views', $module->getShortName());

		if(file_exists('views')) {
			$loader->addPath('views', 'global');
			$loader->addPath('views', 'Global');
		}

		self::$twig = new \Twig_Environment($loader, array(
			'debug'            => Configuration::get('debug.template', 'false') === 'true',
			'auto_reload'      => Kernel::getEnvironment() === "local",
			'charset'          => Configuration::get('templates.charset', 'utf-8'),
			'cache'            => 'cache/twig',
			'strict_variables' => false,
			'autoescape'       => true
		));

		self::$twig->addFilter(new \Twig_SimpleFilter('time_short', function($date) {
			if($date == "now") $date = new \DateTime();
			return $date->format('H:i');
		}));
		self::$twig->addFilter(new \Twig_SimpleFilter('date_short', function($date) {
			if($date == "now") $date = new \DateTime();
			return $date->format('Y-m-d');
		}));
		self::$twig->addFilter(new \Twig_SimpleFilter('date_long', function($date) {
			if($date == "now") $date = new \DateTime();
			return $date->format('jS F Y');
		}));
		self::$twig->addFilter(new \Twig_SimpleFilter('date_uk', function($date) {
			if($date == "now") $date = new \DateTime();
			return $date->format('d/m/Y');
		}));
		self::$twig->getExtension('core')->setDateFormat('Y-m-d H:i');

		$sort_filter = function($value, $key, $direction, $absolute, $natural) {
			usort($value, function($a, $b) use ($key, $direction, $absolute, $natural) {
				if($key) {
					$a = $a[$key];
					$b = $b[$key];
				}

				if($absolute) {
					$a = abs($a);
					$b = abs($b);
				}

				if($direction == "desc" || $direction === true) {
					if($natural)
						return strnatcmp($b, $a);

					if($a == $b) return 0;
					return $a > $b ? -1 : 1;
				}

				if($direction == "asc") {
					if($natural)
						return strnatcmp($a, $b);

					if($a == $b) return 0;
					return $a > $b ? 1 : -1;
				}

				return 0;
			});
			return $value;
		};

		/**
		 * $test = array(
	     *   array("value" => 3),
	     *   array("value" => 1),
	     *   array("value" => 2),
	     *   array("value" => 5),
	     *   array("value" => 4),
	     *   array("value" => -3),
	     *   array("value" => -1),
	     *   array("value" => -2),
	     *   array("value" => -5),
	     *   array("value" => -4)
	     * );
	     *
	     * (the zero argument versions only work on simple arrays!)
	     *
	     * | sort([key, direction, absolute, natural])
	     * | sort()                                          [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
	     * | sort("value", "asc")                            [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]
	     * | sort("value", "desc")                           [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
	     * | sort("value", true)                             [5, 4, 3, 2, 1, -1, -2, -3, -4, -5]
	     * | sort("value", "asc", true)                      [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | sort("value", "asc", true, true)                [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | sort("value", "asc", false, true)               [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
	     *
	     * | sortabs([key, direction])
	     * | sortabs()                                       [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | sortabs("value", "asc")                         [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | sortabs("value", "desc")                        [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
	     *
	     * | natsort([key, direction])
	     * | natsort()                                       [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
	     * | natsort("value", "asc")                         [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5]
	     * | natsort("value", "desc")                        [5, 4, 3, 2, 1, -5, -4, -3, -2, -1]
	     *
	     * | natsortabs([key, direction])
	     * | natsortabs()                                    [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | natsortabs("value", "asc")                      [-1, 1, -2, 2, -3, 3, -4, 4, 5, -5]
	     * | natsortabs("value", "desc")                     [5, -5, -4, 4, -3, 3, 2, -2, 1, -1]
		 */

		self::$twig->addFilter(new \Twig_SimpleFilter("sort", function ($value, array $options = array()) use ($sort_filter) {
			$key       = isset($options[0]) ? $options[0] : null;
			$direction = isset($options[1]) ? $options[1] : "asc";
			$absolute  = isset($options[2]) ? $options[2] : false;
			$natural   = isset($options[3]) ? $options[3] : false;
			return $sort_filter($value, $key, $direction, $absolute, $natural);
		}, array('is_variadic' => true)));

		self::$twig->addFilter(new \Twig_SimpleFilter("natsort", function ($value, array $options = array()) use ($sort_filter) {
			$key       = isset($options[0]) ? $options[0] : null;
			$direction = isset($options[1]) ? $options[1] : "asc";
			return $sort_filter($value, $key, $direction, false, true);
		}, array('is_variadic' => true)));

		self::$twig->addFilter(new \Twig_SimpleFilter("sortabs", function ($value, array $options = array()) use ($sort_filter) {
			$key       = isset($options[0]) ? $options[0] : null;
			$direction = isset($options[1]) ? $options[1] : "asc";
			return $sort_filter($value, $key, $direction, true, false);
		}, array('is_variadic' => true)));

		self::$twig->addFilter(new \Twig_SimpleFilter("natsortabs", function ($value, array $options = array()) use ($sort_filter) {
			$key       = isset($options[0]) ? $options[0] : null;
			$direction = isset($options[1]) ? $options[1] : "asc";
			return $sort_filter($value, $key, $direction, true, true);
		}, array('is_variadic' => true)));
	}
1074273
public function init()
    {
        parent::init();

        $this->visible = Yii::$app->user->can('access-subclients');
        if (!$this->visible) {
            return null;
        }

        if (!$this->sortAttribute) {
            $this->sortAttribute = $this->nameAttribute;
        }
        if ($this->value === null) {
            $this->value = function ($model) {
                if (Yii::$app->user->identity->hasSeller($model->{$this->idAttribute})) {
                    return $model->{$this->nameAttribute};
                } else {
                    return Html::a($model->{$this->nameAttribute}, ['@client/view', 'id' => $model->{$this->idAttribute}]);
                }
            };
        }
        if (!empty($this->grid->filterModel)) {
            if (!isset($this->filterInputOptions['id'])) {
                $this->filterInputOptions['id'] = $this->attribute;
            }
            if ($this->filter === null && strpos($this->attribute, '_like') === false) {
                $this->filter = $this->getDefaultFilter();
            }
        }

        return true;
    }
1011144
public function load()
    {
        $this->extensions = [];
        foreach ($this->getPackages() as $package) {
            [$v, $p] = explode('/', $package['name']);
            $extension = Extension::findBy([
                'vendor' => $v,
                'package' => $p
            ]);
            if (!$extension) {
                $extension = (new Extension())
                    ->vendor($v)
                    ->package($p);
            }
            $extension
                ->version($package['version'] ?? '')
                ->description($package['description'] ?? '')
                ->save();
            $this->extensions[] = $extension;
        }
        return $this;
    }
1213369
protected function load()
    {
        // Select related IDs from aggregation table
        $query = [
            $this->thisField => $this->getParentEntity()->id
        ];

        $relatedObjects = Entity::getInstance()->getDatabase()->find($this->intermediateCollection, $query, [$this->refField => 1]);
        $relatedIds = [];
        foreach ($relatedObjects as $rObject) {
            $relatedIds[] = $rObject[$this->refField];
        }

        // Find all related entities using $relatedIds
        $callable = [
            $this->getEntity(),
            'find'
        ];

        return call_user_func_array($callable, [['id' => ['$in' => $relatedIds]]]);
    }
302013
public function load()
    {
        $settings = $this->getService('com:settings.setting');

        foreach($this->_attributes as $key => $value) {
          $this->_attributes[$key] = $settings->$key;
        }

        return $this;
    }
1075310
private function load()
    {
        if ($this->loaded) {
            return $this;
        }

        if (0 == count($this->dirs)) {
            return $this;
        }

        $loaderResolver = new LoaderResolver(array(
            new YamlLoader()
        ));
        $loader = new DelegatingLoader($loaderResolver);

        $finder = new Finder();
        $finder->files()->in($this->dirs)->name('schemas.yml');

        foreach ($finder as $file) {
            $schemas = $loader->load((string)$file);
            foreach ($schemas as $schema) {
                $this->addSchema($schema);
            }
        }

        $this->loaded = true;

        return $this;
    }
355790
public function init()
    {
        // Get options
        $filter_slug = $this->currentPage;

        // Check sections
        if (!empty($this->options['sections']) && is_array($this->options['sections'])) {
            foreach ($this->options['sections'] as $sectionSlug => $sectionName) {
                if ($sectionSlug !== $this->currentSection) {
                    continue;
                }

                $filter_slug .= '-'.$this->currentSection;
                break;
            }
        }

        /**
         * Build page contents.
         *
         * @var     string  $currentPage
         * @param   array   $contents
         * @return  array   $contents
         */
        $this->fields = apply_filters('ol_zeus_adminpage_'.$filter_slug.'_contents', []);

        // Display main render
        $this->renderFields();
    }
967636
private function initStepViewModel() {
        #first start of Wizard
        #load template from first step
        $currentStep = $this->stepCollectionIterator->current();
        $isFirstStep = $this->getSteps()->isFirst($currentStep);
        if ($isFirstStep) {
            $firstStep = $this->getSteps()->getFirst();
            $this->viewModel->addChild($firstStep->getViewModel(), "wizardContent");
            $firstStepFormName = $firstStep->getViewModel()->getVariable("formName", false);
            if (empty($firstStepFormName))
                throw new \Exception("viewModel variable 'formName' must set for Step '".$firstStep->getName()."'");
        }
        if (!($this->prevButtonDisabled && $isFirstStep)) {
            $this->prevButtonViewModel = new ViewModel();
            $this->prevButtonViewModel->setTemplate("wizard/wizardButton");
            $this->prevButtonViewModel->setVariable("stepActionDirection", "prev");
            $this->prevButtonViewModel->setVariable("id", "prevButton");
        }

        $this->nextButtonViewModel = new ViewModel();
        $this->nextButtonViewModel->setTemplate("wizard/wizardButton");
        $this->nextButtonViewModel->setVariable("stepActionDirection", "next");
        $this->nextButtonViewModel->setVariable("id", "nextButton");

        /**
         * creates breadcrumbPath
         */
        $stepIterator = $this->getSteps()->getIterator();
        while ($stepIterator->valid()) {
            $view = $this->createBreadcrumbItems($stepIterator->current());
            $this->getSteps()->isFirst($stepIterator->current()) ? $view->setVariable("extendCssClass", "active first") : false;
            $this->getSteps()->isLast($stepIterator->current()) ? $view->setVariable("extendCssClass", "last") : false;
            $view->setVariable("breadcrumbStepName", $stepIterator->current()->getName());
            $this->viewModel->addChild($view, "breadcrumbNavigation", true);
            $stepIterator->next();
        }
        $this->resultContent = $this->viewModel;
        $this->process();
    }
884409
protected function initFiles(): array
    {
        $preview = [];
        if (is_array($this->model->{$this->bucket})) {
            foreach ($this->model->{$this->bucket} as $media) {
                $preview[] = $this->prepareFile($media);
            }
        } elseif ($this->model->{$this->bucket}) {
            $preview = $this->prepareFile($this->model->{$this->bucket});
        }
        return $preview;
    }
495936
public function init()
    {
        $client = ClientBuilder::create();
        if (true === is_array($this->hosts) && count($this->hosts) > 0) {
            $client->setHosts($this->hosts);
        }
        $this->client = $client->build();
        try {
            $e = $this->client->search(['index' => '_all', '_source' => false, 'body' => []]);
            /** @var null | Watch $watcher */
            $watcher = null;
            if (null !== $this->watcherClass) {
                if (true === class_exists($this->watcherClass)) {
                    $class = $this->watcherClass;
                    $watcher = new $class;
                }
            } else {
                $watcher = new $this->defaultWatcherClass;
            }
            if (null !== $watcher) {
                $watcher->setClient($this->client);
                $watcher->init();
                $this->watcher = $watcher;
                $this->started = true;
            } else {
                Yii::warning('There is no correct class defined for elasticsearch Watch. Search rolls back to common.');
            }
        } catch (NoNodesAvailableException $e) {
            Yii::warning('Elasticsearch said:' . $e->getMessage());
        }
    }
1021360
public function load()
    {
        if ($this->_isCollectionLoaded == false) {


            $collection = Mage::getResourceModel('catalog/category_collection')->addNameToResult();
            /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */

            foreach ($collection as $category) {
                /** @var $category Mage_Catalog_Model_Category */
                $structure = explode('/', $category->getPath());
                $pathSize = count($structure);
                if ($pathSize > 1) {
                    $path = array();
                    for ($i = 1; $i < $pathSize; $i++) {
                        $path[] = $collection->getItemById($structure[$i])->getName();
                    }
                    $rootCategoryName = array_shift($path);
                    if (!isset($this->_categoriesWithRoots[$rootCategoryName])) {
                        $this->_categoriesWithRoots[$rootCategoryName] = array();
                    }
                    $index = $this->_implodeEscaped('/', $path);

                    $this->_categoriesWithRoots[$rootCategoryName][$index] = array(
                        'entity_id' => $category->getId(),
                        'path' => $category->getPath(),
                        'level' => $category->getLevel(),
                        'position' => $category->getPosition()
                    );

//allow importing by ids.
                    if (!isset($this->_categoriesWithRoots[$structure[1]])) {
                        $this->_categoriesWithRoots[$structure[1]] = array();
                    }
                    $this->_categoriesWithRoots[$structure[1]][$category->getId()] =
                        $this->_categoriesWithRoots[$rootCategoryName][$index];
                }
            }


            $collection = clone $this->_categoryCollection;
            $collection->removeAttributeToSelect();
            $tableName = $collection->getResource()->getEntityTable();
            $collection->getSelect()->from($tableName, ['entity_id', 'website_id', 'email']);

            $this->_byPagesIterator->iterate(
                $this->_categoryCollection,
                $this->_pageSize,
                [[$this, 'addCustomer']]
            );

            $this->_isCollectionLoaded = true;
        }
    }
200465
public function load()
    {
        $this->loadChildClasses();

        list($constructorResolvedOptions, $extraResolvedOptions) = $this->resolveOptions();
        $instance = $this->reflected->newInstanceArgs($constructorResolvedOptions);

        $this->loadExtraOptions($extraResolvedOptions, $instance);

        return $instance;
    }