Create Smarty view object.

@param ContainerInterface $container Slim dependency container
@param Request            $request   PSR-7 request

@return Smarty
516618
public static function create(ContainerInterface $container, Request $request = null)
    {
        if (!isset($request)) {
            $request = $container['request'];
        }

        $view = new Smarty(__DIR__.'/../templates/');
        if (in_array('https', $request->getHeader('X-Forwarded-Proto'))) {
            $request = $request->withUri($request->getUri()->withScheme('https')->withPort(443));
        }

        $smartyPlugins = new SmartyPlugins($container['router'], $request->getUri()->withUserInfo(null));
        $view->registerPlugin('function', 'path_for', [$smartyPlugins, 'pathFor']);
        $view->registerPlugin('function', 'base_url', [$smartyPlugins, 'baseUrl']);

        return $view;
    }
1360905
public function changeTypeAction(Request $request)
    {
        $container = $this->findContainerByRequest($request);

        $type = $request->request->get('type', null);

        $data = [];

        if ($type != $container->getType()) {
            try {
                $removed = $this->getEditor()->getContainerManager()->changeType($container, $type);
            } catch (EditorExceptionInterface $e) {
                return $this->handleException($e);
            }

            if (!empty($removed)) {
                $data['removed'] = $removed;
            }

            $this->validate($container);
            $this->persist($container);
        }

        $data['containers'] = [$this->getViewBuilder()->buildContainer($container)];

        return $this->buildResponse($data, self::SERIALIZE_FULL);
    }
297236
public function createRepositoryFactory(ContainerInterface $container)
    {
        if (empty($this->configFile)) {
            $this->configFile = $container->get('ConfigDirectory') . '/config/database.ini';
        }

        $config = parse_ini_file($this->configFile, true);

        $configuration = new Configuration;

        // Add logger
        $logger = new DebugStack;
        $configuration->setSQLLogger($logger);

        $connection = DriverManager::getConnection(
            [
                'url'     => $config['databaseUrl'],
                'charset' => 'utf8',
            ],
            $configuration
        );
        $transactor = new DoctrineTransactor($connection);

        $repositoryFactory = new RepositoryFactory($config, $connection, $transactor);

        if ($container->has('dispatcher')) {
            $repositoryFactory->setDispatcher($container->get('dispatcher'));
        }

        return $repositoryFactory;
    }
649451
protected function prepare(ContainerInterface $container = null, array $arguments = [])
    {
        $result = [];

        foreach ($arguments as $k => $arg) {
            if (is_array($arg)) {
                $result[$k] = $this->prepare($container, $arg);
                continue;
            } elseif ($arg == '@Container') {
                $result[$k] = $container;
                continue;
            } elseif (strpos($arg, '@') !== 0) {
                $result[$k] = $arg;
                continue;
            }

            $arg = substr($arg, 1);

            if (!$container) {
                throw new ContainerException(sprintf('Unable to resolve dependency for "%s" - missing dependency "%s"', $this->class, $arg));
            }

            $result[$k] = $container->get($arg);
        }

        return $result;
    }
727596
public function createAction(Request $request)
        {

            $oRemoteApp = new RemoteApp();
            $form       = $this->createCreateForm($oRemoteApp);
            $form->handleRequest($request);

            if ($form->isValid()) {

                $sDomain = $oRemoteApp->getDomain();
                if(substr($sDomain,-1,1) !== "/"){
                    $sDomain .= "/";
                    $oRemoteApp->setDomain($sDomain);
                }

                $sModulePath = $oRemoteApp->getApiUrl();
                if(substr($sModulePath,0,1) === "/"){
                    $sModulePath = substr($sModulePath,1);
                    $oRemoteApp->setApiUrl($sModulePath);
                }

                $oRemoteApp->save();

                return $this->redirect($this->generateUrl('remote_app'));
            }

            return $this->render('SlashworksAppBundle:RemoteApp:new.html.twig', array(
                'entity' => $oRemoteApp,
                'form'   => $form->createView(),
            ));
        }
102783
public function createService(ServiceLocatorInterface $container)
    {
        // Retrieve the parent container when under zend-servicemanager v2
        if (method_exists($container, 'getServiceLocator')) {
            $container = $container->getServiceLocator() ?: $container;
        }

        return $this($container, DoctrineWriter::class);
    }
908728
public function initDependencyContainer(Dependency\ContainerInterface $container = null)
    {
        if (null === $container) {
            $container = Dependency\Container::getInstance();
        }

        $this->dependencyContainer = $container;

        return $this;
    }
1186580
public function buildContainer(Model\ContainerInterface $container)
    {
        // Rendering source (for copy containers)
        $source = is_null($container->getCopy()) ? $container : $container->getCopy();

        $view = new ContainerView();
        $attributes = $view->getAttributes()->addClass('cms-container');
        $attributes->setId('cms-container-' . $container->getId());

        $innerAttributes = $view->getInnerAttributes()->addClass('cms-inner-container');

        if ($this->editor->isEnabled()) {
            $content = $container->getContent();

            // Container
            $attributes
                ->setData([
                    'id'       => $container->getId(),
                    'position' => $container->getPosition(),
                    'type'     => $container->getType(),
                    'actions'  => [
                        'add'         => !is_null($content),
                        'edit'        => true,
                        'layout'      => is_null($container->getCopy()),
                        'change_type' => !$container->isNamed() && !$container->isTitled(),
                        'move_up'     => !$container->isFirst(),
                        'move_down'   => !$container->isLast(),
                        'remove'      => !$container->isAlone(),
                    ],
                ]);

            // Inner container
            $innerAttributes
                ->setId('cms-inner-container-' . $source->getId())
                ->setData([
                    'id' => $source->getId(),
                ]);
        }

        // Layout
        $this->editor->getLayoutAdapter()->buildContainer($source, $view);
        $view->content = '<span class="cms-container-anchor">&nbsp;</span>' . $view->content;


        // Plugin
        $this->editor->getContainerPlugin($source->getType())->render($source, $view);

        // Don't build rows if the plugin did generate a content
        if (0 == strlen($view->innerContent)) {
            foreach ($source->getRows() as $row) {
                $view->rows[] = $this->buildRow($row);
            }
        }

        return $view;
    }
1140559
public function provideServiceLayerDependencies(Container $container)
    {
        $container = parent::provideServiceLayerDependencies($container);

        $container = $this->addStoreClient($container);

        return $container;
    }
1251746
public function setContainer(ContainerInterface $container = null)
    {
        $this->abortIf(is_null($container), 'Requires DI container');

        $this->fs = $container->get('filesystem');
        $this->em = $container->get('doctrine.orm.entity_manager');
        $this->target = $container->getParameter('kernel.root_dir').'/../web/media/example/';
        $this->source = $container->get('kernel')->locateResource('@AnimeDbDevBundle/Resource/private/images/');
    }
565239
public function register(Container $container)
    {
        $container->share(get_class($this->package), $this->package)
            ->bindShared(AbstractPackage::class, get_class($this->package));

        $container->share('controller.resolver', function (Container $container) {
            return new ControllerResolver($this->package, $container);
        });

        $container->share('repository.resolver', function (Container $container) {
            return new RepositoryResolver($this->package, $container);
        })->alias('model.resolver', 'repository.resolver');

        $container->share('view.resolver', function (Container $container) {
            return new ViewResolver($this->package, $container);
        });

        $container->share('mvc.resolver', function (Container $container) {
            return new MvcResolver(
                $container->get('controller.resolver'),
                $container->get('repository.resolver'),
                $container->get('view.resolver')
            );
        });

        if ($this->package->app->isWeb()) {
            // Router
            $container->prepareSharedObject(PackageRouter::class)->alias('router', PackageRouter::class);
        }
    }
1148016
protected function addCommandList(
        DependencyContainerInterface $container
    ): DependencyContainerInterface {
        $container[self::COMMAND_LIST] = function (DependencyContainerInterface $container) {
            return $this->getCommandList();
        };

        return $container;
    }
309214
public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
        if ($this->container->has('request') && $this->container->hasScope('request') && $this->container->isScopeActive('request')) {
            $this->request = $this->container->get('request');
        }
    }
22020
protected function getContainerLoader(ContainerInterface $container)
    {
        $locator = new FileLocator($this);
        $resolver = new LoaderResolver([
            new XmlFileLoader($container, $locator),
            new YamlFileLoader($container, $locator),
            new IniFileLoader($container, $locator),
            new PhpFileLoader($container, $locator),
            new DirectoryLoader($container, $locator),
            new ClosureLoader($container),
        ]);

        return new DelegatingLoader($resolver);
    }
178912
public function composeAction(Request $request)
    {
        $admin = $this->getAdmin();

        $admin->checkAccess('compose');
        if (false === $this->get('sonata.dashboard.admin.block')->isGranted('LIST')) {
            throw $this->createAccessDeniedException();
        }

        $id = $request->get($admin->getIdParameter());
        $dashboard = $admin->getObject($id);
        if (!$dashboard) {
            throw $this->createNotFoundException(sprintf('unable to find the dashboard with id : %s', $id));
        }

        $containers = [];

        // separate containers.
        /** @var array $blocks */
        $blocks = $dashboard->getBlocks();

        foreach ($blocks as $block) {
            /** @var Block $block */
            $blockCode = $block->getSetting('code');
            if (null === $block->getParent()) {
                $containers[$blockCode]['block'] = $block;
            }
        }

        return $this->renderWithExtraParams($template = $admin->getTemplate('compose'), [
            'object' => $dashboard,
            'action' => 'edit',
            'containers' => $containers,
            'csrfTokens' => [
                'remove' => $this->getCsrfToken('sonata.delete'),
            ],
        ]);
    }
1347985
public static function instance(/** @noinspection PhpUnusedParameterInspection */
        array $routeParams,
        ContainerInterface $container,
        ServerRequestInterface $request
    ): ResponseInterface {
        $params = [
            'post_create_url' => static::createUrl($container, UserSchema::TYPE, self::METHOD_CREATE),
            'roles'           => static::createApi($container, RolesApi::class)->index()->getData(),
            'model'           => [UserSchema::REL_ROLE => RolesSeed::ROLE_USER],
        ];

        $body = self::view($container, Views::USER_MODIFY_PAGE, $params);

        return new HtmlResponse($body);
    }
673804
static public function run(ContainerInterface $container)
    {
        $request = ServerRequestFactory::fromGlobals();
        $container->set('Request', $request);
        $response = $container->get('HttpDispatcher')->dispatch($request);

        if (is_null($response)) {
            $controller = new Controller($container);
            $response = new TextResponse('Internal server error. Dispatcher returned null response.', 500);
        }

        (new SapiEmitter())->emit($response);
    }