Container example

/** * Return the config form navigation * * @return void */
    public function getNavigationAction()
    {
        $node = (int) $this->Request()->getParam('node');
        $filter = $this->Request()->getParam('filter');
        $repository = $this->getRepository('form');

        $user = Shopware()->Container()->get('auth')->getIdentity();
        /** @var Locale $locale */
        $locale = $user->locale;

        $fallback = $this->getFallbackLocaleId($locale->getId());

        $builder = $repository->createQueryBuilder('form')
            ->leftJoin('form.elements', 'element')
            ->leftJoin('element.translations', 'elementTranslation', Join::WITH, 'elementTranslation.localeId IN(:localeId, :fallbackId)')
            ->leftJoin('form.translations', 'translation', Join::WITH, 'translation.localeId = :localeId')
            ->leftJoin('form.translations', 'translationFallback', Join::WITH, 'translationFallback.localeId = :fallbackId')
            ->leftJoin('form.children', 'children')
            
->method('getStorage')
      ->willReturnMap([
        ['field_storage_config', $this->createMock(EntityStorageInterface::class)],
      ]);
    $entity_type_manager
      ->expects($this->any())
      ->method('getAccessControlHandler')
      ->willReturnMap([
        ['field_storage_config', $storage_access_control_handler],
      ]);

    $container = new Container();
    $container->set('entity_type.manager', $entity_type_manager);
    $container->set('uuid', $this->createMock(UuidInterface::class));
    $container->set('cache_contexts_manager', $this->prophesize(CacheContextsManager::class));
    \Drupal::setContainer($container);

    $this->entity = new FieldStorageConfig([
      'field_name' => 'test_field',
      'entity_type' => 'node',
      'type' => 'boolean',
      'id' => 'node.test_field',
      'uuid' => '6f2f259a-f3c7-42ea-bdd5-111ad1f85ed1',
    ]);
return $this->repository;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * @return CategoryDenormalization */
    public function getCategoryComponent()
    {
        return Shopware()->Container()->get('categorydenormalization');
    }

    /** * Reads all known categories into an array to show it in the category treepanel */
    public function getListAction()
    {
        /** @var array $filter */
        $filter = $this->Request()->getParam('filter', []);
        $node = (int) $this->Request()->getParam('node');
        $preselectedNodes = $this->Request()->getParam('preselected');

        
'source' => $info['source'] ?? 'Default',
            'update_date' => $info['updateDate'] ?? null,
            'update_version' => $info['updateVersion'] ?? null,
            'update_source' => $info['updateSource'] ?? null,
            'capability_update' => !empty($capabilities['update']),
            'capability_install' => !empty($capabilities['install']),
            'capability_enable' => !empty($capabilities['enable']),
            'capability_secure_uninstall' => !empty($capabilities['secureUninstall']),
            'refresh_date' => $refreshDate,
        ];

        $connection = $this->Application()->Container()->get(Connection::class);
        if (empty($id)) {
            $data['added'] = $refreshDate;
            $connection->insert(
                's_core_plugins',
                $data,
                [
                    'added' => 'datetime',
                    'refresh_date' => 'datetime',
                    'update_date' => 'datetime',
                ]
            );
        }

function smarty_function_compileLess($params$template)
{
    $time = $params['timestamp'];
    $output = $params['output'];

    /** @var \Shopware\Components\Theme\PathResolver $pathResolver */
    $pathResolver = Shopware()->Container()->get(\Shopware\Components\Theme\PathResolver::class);

    /** @var \Shopware\Models\Shop\Shop $shop */
    $shop = Shopware()->Container()->get('shop');

    /** @var \Shopware\Models\Theme\Settings $settings */
    $settings = Shopware()->Container()->get(\Shopware\Components\Theme\Service::class)->getSystemConfiguration(
        \Doctrine\ORM\AbstractQuery::HYDRATE_OBJECT
    );

    $file = $pathResolver->getCssFilePath($shop$time);
    $url = $pathResolver->formatPathToUrl($file$shop);

    

class EntityAccessCheckTest extends UnitTestCase {

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
    $container = new Container();
    $container->set('cache_contexts_manager', $cache_contexts_manager);
    \Drupal::setContainer($container);
  }

  /** * Tests the method for checking access to routes. */
  public function testAccess() {
    $route = new Route('/foo/{var_name}', []['_entity_access' => 'var_name.update']['parameters' => ['var_name' => ['type' => 'entity:node']]]);
    /** @var \Drupal\Core\Session\AccountInterface $account */
    $account = $this->prophesize(AccountInterface::class)->reveal();

    
public function __isset($key)
    {
        return $this->has($key);
    }

    /** * @return \Shopware\Components\DispatchFormatHelper */
    public function getNameFormatter()
    {
        if ($this->nameFormatter === null) {
            $this->nameFormatter = Shopware()->Container()->get('shopware.components.dispatch_format_helper');
        }

        return $this->nameFormatter;
    }

    /** * {@inheritdoc} */
    public function getAttribute($attribute$default = null)
    {
        return $this->attributes->get($attribute$default);
    }
public function getShopsAction()
    {
        $shops = Shopware()->Db()->fetchAll('SELECT id, name FROM s_core_shops');
        $this->View()->assign([
            'success' => true,
            'data' => $shops,
        ]);
    }

    public function getConfigAction()
    {
        Shopware()->Container()->get(Zend_Cache_Core::class)->remove(CacheManager::ITEM_TAG_CONFIG);
        $this->View()->assign([
            'success' => true,
            'data' => $this->prepareConfigData(),
        ]);
    }

    /** * Gets a list of id-name of all active shops */
    public function getActiveShopsAction()
    {
        
/** * @coversDefaultClass \Drupal\Core\DependencyInjection\Container * @group DependencyInjection */
class ContainerTest extends UnitTestCase {

  /** * Tests serialization. */
  public function testSerialize() {
    $container = new Container();
    $this->expectException(\AssertionError::class);
    serialize($container);
  }

}
if ($query !== '') {
            $filter[] = [
                'property' => 'name',
                'value' => $query,
            ];
        }

        $query = $this->getRepository()->getSupplierListQuery($filter$sort$limit$offset);
        $total = $this->get('models')->getQueryCount($query);

        $suppliers = $query->getArrayResult();
        $mediaService = Shopware()->Container()->get(MediaServiceInterface::class);

        foreach ($suppliers as &$supplier) {
            $supplier['description'] = strip_tags((string) $supplier['description']);
            $supplier['image'] = $mediaService->getUrl($supplier['image']);
        }
        unset($supplier);

        $this->View()->assign([
            'success' => true,
            'data' => $suppliers,
            'total' => $total,
        ]);


        $this->View()->loadTemplate('frontend/search/fuzzy.tpl');

        $minLengthSearchTerm = $this->get(Shopware_Components_Config::class)->get('minSearchLenght');
        if (\strlen($term) < (int) $minLengthSearchTerm) {
            return;
        }

        $context = $this->get(ContextServiceInterface::class)->getShopContext();

        $criteria = Shopware()->Container()->get(StoreFrontCriteriaFactoryInterface::class)
            ->createSearchCriteria($this->Request()$context);

        $result = $this->get(ProductSearchInterface::class)->search($criteria$context);
        $products = $this->convertProducts($result);

        if ($this->get(Shopware_Components_Config::class)->get('traceSearch', true)) {
            $this->get('shopware_searchdbal.search_term_logger')->logResult(
                $criteria,
                $result,
                $context->getShop()
            );
        }
 elseif (!empty($_SERVER['REQUEST_URI'])) {
            $record['extra']['request'] = [
                'uri' => $_SERVER['REQUEST_URI'],
                'method' => $_SERVER['REQUEST_METHOD'],
                'query' => $this->filterRequestUserData($_GET),
                'post' => $this->filterRequestUserData($_POST),
            ];
        } else {
            $record['extra']['request'] = 'Could not process request data';
        }

        if (Shopware()->Container()->initialized('shop')) {
            $record['extra']['session'] = Shopware()->Session();
            $record['extra']['shopId'] = Shopware()->Shop()->getId() ?: null;
            $record['extra']['shopName'] = Shopware()->Shop()->getName() ?: null;
        } else {
            $record['extra']['shop'] = 'No shop data available';
        }

        if (!empty($_SESSION) && \is_object($_SESSION['Shopware']['Auth'])) {
            $record['extra']['session'] = [
                'userId' => $_SESSION['Shopware']['Auth']->id,
                'roleId' => $_SESSION['Shopware']['Auth']->roleID,
            ];
$this->View()->assign(['success' => false, 'message' => 'Form not found']);

            return;
        }

        $clonedForm = $result->getClone();
        $clonedForm->setName('Copy of ' . $result->getName());

        $this->getManager()->persist($clonedForm);
        $this->getManager()->flush();

        $persister = Shopware()->Container()->get(DataPersister::class);
        $persister->cloneAttribute('s_cms_support_attributes', $id$clonedForm->getId());

        $this->View()->assign(['success' => true]);
    }

    public function getFieldsAction()
    {
        $id = (int) $this->Request()->getParam('formId');
        if ($id === 0) {
            $this->View()->assign(['success' => false, 'message' => 'No valid form Id']);

            
$pool = new ArrayAdapter();
        $item = $pool->getItem('foo');
        $item->set(234);

        $computationService = new class() {
            public function __invoke(CacheItem $item)
            {
                return 123;
            }
        };

        $container = new Container();
        $container->set('computation_service', $computationService);
        $container->set('cache_pool', $pool);

        $reverseContainer = new ReverseContainer($containernew ServiceLocator([]));

        $msg = EarlyExpirationMessage::create($reverseContainer[$computationService, '__invoke']$item$pool);

        $this->assertSame('cache_pool', $msg->getPool());
        $this->assertSame($pool$msg->findPool($reverseContainer));

        $this->assertSame('foo', $msg->getItem()->getKey());
        
class Shopware_Controllers_Backend_UpdateWizard extends Shopware_Controllers_Backend_ExtJs
{
    public function indexAction()
    {
        /** @var Connection $connection */
        $connection = $this->get(\Doctrine\DBAL\Connection::class);
        $sql = "INSERT IGNORE INTO `s_core_config_elements` (`id`, `form_id`, `name`, `value`, `label`, `description`, `type`, `required`, `position`, `scope`) VALUES (NULL, '0', 'updateWizardStarted', 'b:1;', '', '', 'checkbox', '0', '0', '1');";
        $connection->executeUpdate($sql);

        Shopware()->Container()->get(\Shopware\Components\CacheManager::class)->clearConfigCache();
    }

    public function updateAction()
    {
        $pluginCheck = new \ShopwarePlugins\SwagUpdate\Components\PluginCheck($this->container);

        /** @var PluginLicenceService $licenceService */
        $licenceService = $this->get(\Shopware\Bundle\PluginInstallerBundle\Service\PluginLicenceService::class);

        /** @var AccountManagerService $accountService */
        $accountService = $this->get(\Shopware\Bundle\PluginInstallerBundle\Service\AccountManagerService::class);

        
Home | Imprint | This part of the site doesn't use cookies.