Grant evaluation for adding content on top of a container
@param Container $container The container
@return GrantResult Returns the grant result telling if creation is allowed
344815
function GrantAddContentToContainer(Container $container)
    {
        //dummy content for evaluation
        $content = new Content();
        $content->SetUserGroup($container->GetUserGroup());
        $containerRights = $container->GetUserGroupRights();
        if ($containerRights)
        {
            $content->SetUserGroupRights($containerRights->GetContentRights());
        }
        return $this->Grant(BackendAction::Create(), $content);
    }
413843
public function process(ContainerBuilder $container)
    {
        $this->documentMap = $container->get('graviton.document.map');

        $map = [];
        foreach ($this->documentMap->getDocuments() as $document) {
            $restrictionFields = $this->documentMap->getFieldNamesFlat(
                $document,
                '',
                '',
                function ($field) {
                    return $field->getRestrictions();
                },
                true
            );

            $finalRestrictionFields = [];
            foreach ($restrictionFields as $key => $field) {
                // cleanup name! .0. has to be .. for rql!
                $key = preg_replace('@\.([0-9]+)\.@i', '..', $key);
                $finalRestrictionFields[$key] = $field->getRestrictions();
            }

            $map[$document->getClass()] = $finalRestrictionFields;
        }

        $container->setParameter('graviton.document.restriction.fields', $map);
    }
1326643
public function addToFormContainer($container)
	{
		/** @var Nette\Application\UI\Form $form */
		$form = $container->lookup('Nette\Application\UI\Form');
		$translator = $form->getTranslator();
		$main_options = [];

		/**
		 * First foreach for filling "main" select
		 */
		foreach ($this->group_actions as $id => $action) {
			$main_options[$id] = $action->getTitle();
		}

		$container->addSelect('group_action', '', $main_options)
			->setPrompt('ublaboo_datagrid.choose');

		/**
		 * Second for creating select for each "sub"-action
		 */
		foreach ($this->group_actions as $id => $action) {
			$control = null;

			if ($action instanceof GroupSelectAction) {
				if ($action->hasOptions()) {
					if ($action instanceof GroupMultiSelectAction) {
						$control = $container->addMultiSelect($id, '', $action->getOptions());
						$control->setAttribute('data-datagrid-multiselect-id', static::ID_ATTRIBUTE_PREFIX . $id);
						$control->setAttribute('data-style', 'hidden');
						$control->setAttribute('data-selected-icon-check', DataGrid::$icon_prefix . 'check');
					} else {
						$control = $container->addSelect($id, '', $action->getOptions());
					}

					$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id);
				}

			} elseif ($action instanceof GroupTextAction) {
				$control = $container->addText($id, '');

				$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id)
					->addConditionOn($container['group_action'], Form::EQUAL, $id)
						->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'))
					->endCondition();

			} elseif ($action instanceof GroupTextareaAction) {
				$control = $container->addTextarea($id, '');

				$control->setAttribute('id', static::ID_ATTRIBUTE_PREFIX . $id)
					->addConditionOn($container['group_action'], Form::EQUAL, $id)
						->setRequired($translator->translate('ublaboo_datagrid.choose_input_required'));
			}

			if ($control) {
				/**
				 * User may set a class to the form control
				 */
				if ($class = $action->getClass()) {
					$control->setAttribute('class', $class);
				}

				/**
				 * User may set additional attribtues to the form control
				 */
				foreach ($action->getAttributes() as $name => $value) {
					$control->setAttribute($name, $value);
				}
			}
		}

		foreach ($this->group_actions as $id => $action) {
			$container['group_action']->addCondition(Form::EQUAL, $id)
				->toggle(static::ID_ATTRIBUTE_PREFIX . $id);
		}

		$container['group_action']->addCondition(Form::FILLED)
			->toggle(strtolower($this->datagrid->getName()) . 'group_action_submit');

		$container->addSubmit('submit', 'ublaboo_datagrid.execute')
			->setValidationScope([$container])
			->setAttribute('id', strtolower($this->datagrid->getName()) . 'group_action_submit');

		if ($form instanceof Nette\ComponentModel\IComponent) {
			$form->onSubmit[] = [$this, 'submitted'];
		}
	}
522939
public static function prepareContainer(Container $container)
    {
        if ( ! isset($container['config'])) {
            $container['config'] = [];
        }
        if ( ! isset($container['files'])) {
            $container['files'] = new Filesystem();
        }
        if ( ! isset($container['providers'])) {
            $container['providers'] = [];
        }
        $providers = $container['providers'];
        $providers[] = 'Consolet\DefaultCommandsProvider';
        $container['providers'] = $providers;
        return $container;
    }
58832
public function authorisation(Container $container)
    {
        $auth   = new Authorisation();
        $config = $container->get('config');

        foreach ((array) $config->get('user.policies') as $name => $policy) {
            if ($policy instanceof ClassMeta || (is_string($policy) && class_exists($policy))) {
                $instance = $container->newInstance($policy);

                if (is_subclass_of($instance, PolicyInterface::class)) {
                    $auth->addPolicy($name, $instance);
                } elseif (is_subclass_of($instance, PolicyProviderInterface::class)) {
                    $auth->registerPolicyProvider($instance);
                }
            } elseif ($policy === false) {
                continue;
            } else {
                throw new \InvalidArgumentException(sprintf(
                    'Please register instance of %s or %s',
                    PolicyInterface::class,
                    PolicyProviderInterface::class
                ));
            }
        }

        /** @var EventDispatcher $dispatcher */
        $this->dispatcher->triggerEvent('onLoadAuthorisationPolicies', ['auth' => $auth]);

        return $auth;
    }
873611
public function register(Container $container)
    {
        /** @var Config $configuration */
        $configuration = $container['config'];

        $client = new Client([
            'timeout' => $configuration->timeout,
            'verify' => $configuration->sslVerifyHost,
        ]);

        return $client;
    }
360476
public function make(Container $container)
    {
        $this->container = $container;

        $this->container->call([$this, 'dispatch']);

        $this->register();

        return $this;
    }
1161266
static function LastContainerModLog(Container $container)
    {
        $lastLog = self::LastContainerLog($container);
        $containerContents = ContainerContent::Schema()->FetchByContainer(false, $container);
        foreach ($containerContents as $containerContent)
        {
            $content = $containerContent->GetContent();
            $contentLog = self::LastContentModLog($content, null);
            if (self::IsAfter($contentLog, $lastLog))
            {
                $lastLog = $contentLog;
            }
        }
        return $lastLog;
    }
542735
public function containerPause($container)
    {
        return $this->browser->post(
            $this->uri->expand(
                '/containers/{container}/pause',
                array(
                    'container' => $container
                )
            )
        )->then(array($this->parser, 'expectEmpty'));
    }
935608
public function get($container = null)
    {
        if ($container) {
            return $container->get($this->id);
        }
        return Ioc::container()->get($this->id);
    }
790584
public static function getInstance(Container $container = null)
    {
        if (null === self::$instance) {
            self::$instance = new Core($container);
        }
        return self::$instance;
    }
468562
public function register(Container $container)
    {
        /**
         * @param Container $container A container instance.
         * @return Container The Collection of DatabaseSourceConfig, in a Container.
         */
        $container['databases/config'] = function (Container $container) {
            $config = $container['config'];
            $databases = $config['databases'];
            $configs = new Container();
            foreach ($databases as $dbIdent => $dbOptions) {
                $configs[$dbIdent] = function () use ($dbOptions) {
                    return new DatabaseConfig($dbOptions);
                };
            }
            return $configs;
        };

        /**
         * @param Container $container A container instance.
         * @return Container
         */
        $container['databases'] = function (Container $container) {
            $config = $container['config'];
            $databases = $config['databases'];
            $dbs = new Container();
            $origContainer = $container;
            foreach ($databases as $dbIdent => $dbOptions) {
                unset($dbOptions);

                /**
                 * @param Container $container A container instance.
                 * @return PDO
                 */
                $dbs[$dbIdent] = function () use ($dbIdent, $origContainer) {
                    $dbConfigs = $origContainer['databases/config'];
                    $dbConfig = $dbConfigs[$dbIdent];

                    $type = $dbConfig['type'];
                    $host = $dbConfig['hostname'];

                    $database = $dbConfig['database'];
                    $username = $dbConfig['username'];
                    $password = $dbConfig['password'];

                    // Set UTf-8 compatibility by default. Disable it if it is set as such in config
                    $extraOptions = null;
                    if (!isset($dbConfig['disable_utf8']) || !$dbConfig['disable_utf8']) {
                        $extraOptions = [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'];
                    }

                    if ($type == 'sqlite') {
                        $dsn = $type.':'.$database;
                    } else {
                        $dsn = $type.':host='.$host.';dbname='.$database;
                    }
                    $db = new PDO($dsn, $username, $password, $extraOptions);

                    // Set PDO options
                    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                    if ($type == 'mysql') {
                        $db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
                    }
                    return $db;
                };
            }
            return $dbs;
        };

        /**
         * The (default) database configuration.
         *
         * @param Container $container A container instance.
         * @return DatabaseSourceConfig
         */
        $container['database/config'] = function (Container $container) {
            $config = $container['config'];
            $databaseIdent = $config['default_database'];
            return $container['databases/config'][$databaseIdent];
        };

        /**
         * The (default) database service, as a PDO object.
         *
         * @param Container $container A container instance.
         * @throws Exception If the database configuration is invalid.
         * @return PDO
         */
        $container['database'] = function (Container $container) {
            $config = $container['config'];
            $databaseIdent = $config['default_database'];
            $databases = $container['databases'];
            if (!isset($databases[$databaseIdent])) {
                throw new Exception(
                    sprintf('The database "%s" is not defined in the "databases" configuration.', $databaseIdent)
                );
            }
            return $databases[$databaseIdent];
        };
    }
664002
public function register(Container $container)
    {
        $container['aura.html.locatorFactory'] = function () {
            return new HelperLocatorFactory();
        };
        $container['aura.html.locator'] = function (Container $container) {
            return $container['aura.html.locatorFactory']->newInstance();
        };
        $container['aura.html.escaper'] = function (Container $container) {
            return $container['aura.html.locator']->escape();
        };
    }
1308906
protected function FormUrl(Container $container = null)
    {
        
        $args = array();
        if ($container)
        {
            $args['container'] = $container->GetID();
        }
        return BackendRouter::ModuleUrl(new ContainerForm(), $args);
    }
911825
protected function setupContainer(Container $container)
    {
        $this->container = $container;

        if (!$this->container->has('config')) {
            $this->container['config'] = new Fluent;
        }
    }
1304697
protected function configureContainer(Container $container)
    {
        /* @var $application Application */
        $application = $container->getEntity();
        $job         = $application->getJob();

        /** @var $settings \Applications\Entity\Settings */
        $settings = ($user = $job->getUser()) ? $user->getSettings('Applications') : null;
        $formSettings = $settings ? $settings->getApplyFormSettings() : null;

        if ($formSettings && $formSettings->isActive()) {
            $container->disableElements($formSettings->getDisableElements());
            return;
        }

        $config = $this->config;
        $config = isset($config['form_elements_config']['Applications/Apply']['disable_elements'])
                ? $config['form_elements_config']['Applications/Apply']['disable_elements']
                : null;
        if ($config) {
            $container->disableElements($config);
        }
    }
305723
public function register(Container $container)
    {
        $app = $container->get('application');

        $container->share(WebApplication::class, $app);

        // Input
        $container->share(Input::class, function (Container $container) use ($app) {
            return PsrInput::create($app->getRequest());
        })->bindShared(PsrInput::class, Input::class);

        // Request
//        $container->share(ServerRequest::class, $app->getRequest())
//            ->alias(ServerRequestInterface::class, ServerRequest::class);

        // Environment
        $container->share(WebEnvironment::class, $app->getEnvironment());
        $container->share(Browser::class, $app->getEnvironment()->getBrowser());
        $container->share(Platform::class, $app->getEnvironment()->getPlatform());

        // Uri
        $container->share(UriData::class, function (Container $container) use ($app) {
            return $app->getServer()->getUriData();
        });
    }