Initialize ordering.

@throws \InvalidArgumentException
515357
private function initDirection()
    {
        if (null !== $this->orderBy) {
            switch ($this->direction) {
                case 'ASC':
                case 'DESC':
                    $this->orderBy = [$this->orderBy => $this->direction];
                    break;

                default:
                    throw new \InvalidArgumentException(sprintf('"direction" option should be set with "orderBy" and should be ASC or DESC'));
                    break;
            }
        }
    }
1318438
protected function init()
    {
        if (null === $this->items) {
            list($constraints, $sorting, $joins) = $this->translate($this->filter, $this->sorting);

            if (empty($constraints)) {
                $constraints = '';
            } else {
                $constraints = ' WHERE ' . implode(' AND ', $constraints);
            }

            if ($this->prefetch) {
                $this->initEntities($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            } else {
                $this->initKeys($constraints, $this->makeJoins($joins), $this->makeOrderBy($sorting, $joins));
            }

            $this->rewind();
        }
    }
541264
public function initialize()
    {
        if (empty($this->columnFilters)) {
            return;
        }

        $this->validNumberOfFilters();

        foreach ($this->all() as $filter) {
            if ($filter instanceof Initializable) {
                $filter->initialize();
            }
        }

        $this->validNumberOfFilters();

        $filters = collect($this->columnFilters);

        if ($filters->last() === null) {
            $filters->pop();
            $filters->push(new Control());
        }

        $this->columnFilters = $filters;

        $this->prepareView();
    }
85079
public function initializeArguments()
    {
        parent::initializeArguments();

        $this->registerTagAttribute('quality', 'int', 'Specifies the image quality for jpeg', false);
        $this->registerTagAttribute('greyscale', 'bool', 'Should be image be rendered as greyscale?', false);
        $this->registerTagAttribute('grayscale', 'bool', 'Should be image be rendered as greyscale?', false);
    }
232834
protected function initializeClassBuilder()
    {
        // build the mock class
        $builder = new ClassBuilder();
        if (class_exists($this->className)) {
            $builder->setExtends($this->className);
        } elseif (interface_exists($this->className)) {
            $builder->addInterface($this->className);
        } else {
            throw new \InvalidArgumentException("Class or interface " . $this->className . " does not exist");
        }

        // every mocked method goes through this invocation, which delegates
        // the retrieval of the correct Spec to this Instance's Ordering constraint.
        $resolveCall = function (Invocation $inv) {
            $spec = $this->ordering->nextSpec($inv->getMethodName());
            return $spec->doInvocation($inv);
        };

        return $this->addMethodsToBuilder($builder, $resolveCall);
    }
576290
protected function initialize()
    {
        ArrayRepository::initialize();

        $verbose = $this->verbose;

        /** @var VcsDriver $driver */
        $driver = $this->getDriver();
        if (!$driver) {
            throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
        }

        $this->versionParser = new VersionParser();
        if (!$this->loader) {
            $this->loader = new ArrayLoader($this->versionParser);
        }

        try {
            if ($driver->hasComposerFile($driver->getRootIdentifier())) {
                $data = $driver->getComposerInformation($driver->getRootIdentifier());
                $this->packageName = !empty($data['name']) ? $data['name'] : null;
            }
        } catch (\Exception $e) {
            if ($verbose) {
                $this->io->write('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
            }
        }

        foreach ($driver->getTags() as $tag => $identifier) {
            $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
            if ($verbose) {
                $this->io->write($msg);
            } else {
                $this->io->overwrite($msg, false);
            }

            // strip the release- prefix from tags if present
            $tag = str_replace('release-', '', $tag);

            if (!$parsedTag = $this->validateTag($tag)) {
                if ($verbose) {
                    $this->io->write('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
                }
                continue;
            }

            try {
                if (!$data = $driver->getComposerInformation($identifier)) {
                    if ($verbose) {
                        $this->io->write('<warning>Skipped tag '.$tag.', no composer file</warning>');
                    }
                    continue;
                }

                // manually versioned package
                if (isset($data['version'])) {
                    $data['version_normalized'] = $this->versionParser->normalize($data['version']);
                } else {
                    // auto-versioned package, read value from tag
                    //set version without namespace
                    $data['version'] = $this->_getBranchWithoutNamespace($tag);
                    $data['version_normalized'] = $parsedTag;
                }

                //set package namespace to generate package name based upon repository name
                $data['namespace'] = isset($data['namespace'])
                    ? $data['namespace'] : $this->_getBranchNamespace($tag);

                // make sure tag packages have no -dev flag
                $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
                $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);

                // broken package, version doesn't match tag
                if ($data['version_normalized'] !== $parsedTag) {
                    if ($verbose) {
                        $this->io->write('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
                    }
                    continue;
                }

                if ($verbose) {
                    $this->io->write('Importing tag '.$tag.' ('.$data['version_normalized'].')');
                }

                $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
            } catch (\Exception $e) {
                if ($verbose) {
                    $this->io->write('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found' : $e->getMessage()).'</warning>');
                }
                continue;
            }
        }

        if (!$verbose) {
            $this->io->overwrite('', false);
        }

        foreach ($driver->getBranches() as $branch => $identifier) {
            $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
            if ($verbose) {
                $this->io->write($msg);
            } else {
                $this->io->overwrite($msg, false);
            }

            if (!$parsedBranch = $this->validateBranch($branch)) {
                if ($verbose) {
                    $this->io->write('<warning>Skipped branch '.$branch.', invalid name</warning>');
                }
                continue;
            }

            try {
                if (!$data = $driver->getComposerInformation($identifier)) {
                    if ($verbose) {
                        $this->io->write('<warning>Skipped branch '.$branch.', no composer file</warning>');
                    }
                    continue;
                }

                // branches are always auto-versioned, read value from branch name
                // set branch name without package namespace
                $data['version'] = $this->_getBranchWithoutNamespace($branch);
                //set package namespace to generate package name based upon repository name
                $data['namespace'] = isset($data['namespace'])
                    ? $data['namespace'] : $this->_getBranchNamespace($branch);
                $data['version_normalized'] = $parsedBranch;

                // make sure branch packages have a dev flag
                if ('dev-' === substr($parsedBranch, 0, 4) || '9999999-dev' === $parsedBranch) {
                    $data['version'] = 'dev-' . $data['version'];
                } else {
                    $data['version'] = preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
                }

                if ($verbose) {
                    $this->io->write('Importing branch '.$branch.' ('.$data['version'].')');
                }

                $packageData = $this->preProcess($driver, $data, $identifier);
                $package = $this->loader->load($packageData);
                if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
                    throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
                }
                $this->addPackage($package);
            } catch (TransportException $e) {
                if ($verbose) {
                    $this->io->write('<warning>Skipped branch '.$branch.', no composer file was found</warning>');
                }
                continue;
            } catch (\Exception $e) {
                if (!$verbose) {
                    $this->io->write('');
                }
                $this->branchErrorOccurred = true;
                $this->io->write('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
                $this->io->write('');
                continue;
            }
        }
        $driver->cleanup();

        if (!$verbose) {
            $this->io->overwrite('', false);
        }

        if (!$this->getPackages()) {
            throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
        }
    }
1244116
public function init()
    {
        $this->container = $this->initContainer();

        if ($this->container->has(ServerRequestInterface::class)) {
            $this->baseRequest = $this->container->get(ServerRequestInterface::class);
        }
        
        if ($this->container->has(ResponseInterface::class)) {
            $this->baseResponse = $this->container->get(ResponseInterface::class);
        }
    }
1049499
public function _construct()
    {
        $this->_init(
            \Dotdigitalgroup\Email\Model\Order::class,
            \Dotdigitalgroup\Email\Model\ResourceModel\Order::class
        );
    }
510867
protected function initRootElement()
    {
        if ($this->domDocument->hasChildNodes()) {
            foreach ($this->domDocument->childNodes as $node) {
                if ($node instanceof \DOMElement) {
                    $this->rootElement = $this->getElementHandler($node, $this);
                    break;
                }
            }
        } else {
            throw new \InvalidArgumentException('Document seems to be invalid', __LINE__);
        }
    }
674986
public function setAccessorOrder($order, array $customOrder = []): void
    {
        if (! \in_array($order, [self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM], true)) {
            throw new InvalidArgumentException(\sprintf('The accessor order "%s" is invalid.', $order));
        }

        foreach ($customOrder as $name) {
            if (! \is_string($name)) {
                throw new InvalidArgumentException(\sprintf('$customOrder is expected to be a list of strings, but got element of value %s.', \var_export($name, true)));
            }
        }

        $this->accessorOrder = $order;
        $this->customOrder = \array_flip($customOrder);
        $this->sortProperties();
    }
269870
public void order(Orderer orderer) throws InvalidOrderingException {
        if (getTest() instanceof Orderable) {
            Orderable adapter = (Orderable) getTest();
            adapter.order(orderer);
        }
    }
701679
public function setOrder()
    {
        // set order position if exist
        $order = [];
        foreach ($this->data['order'] as $alias => $params) {

            $order = array_flip($order);

            if (empty($params) === false) {

                foreach ($params as $field => $sort) {
                    $order[] = $alias . '.' . $field . ' ' . $sort;
                }
            }
        }

        $this->builder->orderBy($order);

        return null;
    }
56676
protected function Init()
    {
        $sql = Access::SqlBuilder();
        $tbl = Site::Schema()->Table();
        $order = $sql->OrderList($sql->OrderAsc($tbl->Field('Name')));
        $sites = Site::Schema()->Fetch(false, null, $order);
        $this->sites = array();
        foreach ($sites as $site)
        {
            if (self::Guard()->Allow(BackendAction::Read(), $site))
            {
                $this->sites[] = $site;
            }
        }
        return parent::Init();
    }
740850
protected function init()
    {
        if (true===$this->isInited) {
            return;
        }

        $this->_cleanFilesStack();

        if (empty($this->__adapter_type)) {
            $this->_guessAdapterType();
        }

        if (!empty($this->__adapter_type)) {
            if (class_exists($this->__adapter_type)) {
                $this->__adapter = new $this->__adapter_type;
                if (!($this->__adapter instanceof AbstractCompressorAdapter)) {
                    throw new \LogicException(
                        sprintf('Compressor adapter must extend class "%s" (having object "%s")!', "Assets\AbstractCompressorAdapter", $this->__adapter_type)
                    );
                }
            } else {
                throw new \RuntimeException(
                    sprintf('Compressor adapter for type "%s" doesn\'t exist!', $this->__adapter_type)
                );
            }
        }

        $this->isInited = true;
    }
331466
public function init()
    {
        $extensions = [];

        if (empty($this->extensionClasses) && empty($this->userConfig)) {
            return;
        }

        foreach ($this->extensionClasses as $extensionClass) {
            if (!class_exists($extensionClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Extension class "%s" does not exist',
                    $extensionClass
                ));
            }

            $extension = new $extensionClass();

            if (!$extension instanceof ExtensionInterface) {
                throw new \InvalidArgumentException(sprintf(
                    // add any manually specified extensions
                    'Extension "%s" must implement the PhpBench\\Extension interface',
                    get_class($extension)
                ));
            }

            $extensions[] = $extension;

            $this->config = array_merge(
                $this->config,
                $extension->getDefaultConfig()
            );
        }

        $diff = array_diff(array_keys($this->userConfig), array_keys($this->config));

        if ($diff) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown configuration keys: "%s". Permitted keys: "%s"',
                implode('", "', $diff), implode('", "', array_keys($this->config))
            ));
        }

        $this->config = array_merge(
            $this->config,
            $this->userConfig
        );

        foreach ($extensions as $extension) {
            $extension->load($this);
        }
    }
1068217
public function init()
    {
        // Initialize filepath with configs
        $funcs = $this->getFunctions('Setting', [
            'admin-bar',
            'admin-footer',
            'admin-menu-order',
            'admin-meta-boxes',
            'comments-fields-order',
            'jpeg-quality',
        ]);

        // Check functions
        if (empty($funcs)) {
            return;
        }

        // Iterate on functions
        foreach ($funcs as $key => $args) {
            $this->$func($args);
        }
    }
1347376
protected function init()
    {
        $this->addToStoreList('sorting', SortingListStore::class);
        $this->addToStoreList('category', ListByCategoryStore::class);
        $this->addToStoreList('brand', ListByBrandStore::class);
        $this->addToStoreList('active', ActiveListStore::class);
        $this->addToStoreList('promo_block', ListByPromoBlockStore::class);
    }