當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ServiceLink::getService方法代碼示例

本文整理匯總了PHP中Oro\Bundle\EntityConfigBundle\DependencyInjection\Utils\ServiceLink::getService方法的典型用法代碼示例。如果您正苦於以下問題:PHP ServiceLink::getService方法的具體用法?PHP ServiceLink::getService怎麽用?PHP ServiceLink::getService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Oro\Bundle\EntityConfigBundle\DependencyInjection\Utils\ServiceLink的用法示例。


在下文中一共展示了ServiceLink::getService方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onProcessAfter

 /**
  * @param StrategyEvent $event
  */
 public function onProcessAfter(StrategyEvent $event)
 {
     $entity = $event->getEntity();
     /** @var OwnershipMetadataProvider $metadataProvider */
     $metadataProvider = $this->metadataProviderLink->getService();
     $organizationField = $metadataProvider->getMetadata(ClassUtils::getClass($entity))->getGlobalOwnerFieldName();
     if (!$organizationField) {
         return;
     }
     /** @var SecurityFacade $securityFacade */
     $securityFacade = $this->securityFacadeLink->getService();
     /**
      * We should allow to set organization for entity only in case of console import.
      * If import process was executed from UI (grid's import), current organization for entities should be set.
      */
     $organization = $this->getPropertyAccessor()->getValue($entity, $organizationField);
     if ($organization && $securityFacade->getOrganization() && $organization->getId() == $securityFacade->getOrganizationId()) {
         return;
     }
     $organization = $securityFacade->getOrganization();
     if (!$organization) {
         $organization = $this->getDefaultOrganization();
     }
     if (!$organization) {
         return;
     }
     $this->getPropertyAccessor()->setValue($entity, $organizationField, $organization);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:31,代碼來源:ImportStrategyListener.php

示例2: getContext

 /**
  * Gets context this strategy is working in
  *
  * @throws \RuntimeException
  * @return PermissionGrantingStrategyContextInterface
  */
 protected function getContext()
 {
     if ($this->contextLink === null) {
         throw new \RuntimeException('The context link is not set.');
     }
     return $this->contextLink->getService();
 }
開發者ID:noglitchyo,項目名稱:pim-community-dev,代碼行數:13,代碼來源:PermissionGrantingStrategy.php

示例3: preUpload

 /**
  * Update attachment entity before upload
  *
  * @param File $entity
  */
 public function preUpload(File $entity)
 {
     if ($entity->isEmptyFile()) {
         if ($this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setFilename(null);
         $entity->setExtension(null);
         $entity->setOriginalFilename(null);
     }
     if ($entity->getFile() !== null && $entity->getFile()->isFile()) {
         $entity->setOwner($this->securityFacadeLink->getService()->getLoggedUser());
         $file = $entity->getFile();
         if ($entity->getFilename() !== null && $this->filesystem->has($entity->getFilename())) {
             $this->filesystem->delete($entity->getFilename());
         }
         $entity->setExtension($file->guessExtension());
         if ($file instanceof UploadedFile) {
             $entity->setOriginalFilename($file->getClientOriginalName());
             $entity->setMimeType($file->getClientMimeType());
             $entity->setFileSize($file->getClientSize());
         } else {
             $entity->setOriginalFilename($file->getFileName());
             $entity->setMimeType($file->getMimeType());
             $entity->setFileSize($file->getSize());
         }
         $entity->setFilename(uniqid() . '.' . $entity->getExtension());
         if ($this->filesystem->getAdapter() instanceof MetadataSupporter) {
             $this->filesystem->getAdapter()->setMetadata($entity->getFilename(), ['contentType' => $entity->getMimeType()]);
         }
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:37,代碼來源:AttachmentManager.php

示例4: onClear

 /**
  * @param OnClearEventArgs $event
  */
 public function onClear(OnClearEventArgs $event)
 {
     /** @var SecurityContextInterface $securityContext */
     $securityContext = $this->securityContextLink->getService();
     $className = $event->getEntityClass();
     $token = $securityContext->getToken();
     if (!$token) {
         return;
     }
     $user = $token->getUser();
     if (is_object($user) && (!$className || $className == ClassUtils::getRealClass($user))) {
         $user = $this->refreshEntity($user);
         if ($user) {
             $token->setUser($user);
         } else {
             $securityContext->setToken(null);
             $token = null;
         }
     }
     if ($token && $token instanceof OrganizationContextTokenInterface) {
         $organization = $token->getOrganizationContext();
         if (is_object($organization) && (!$className || $className == ClassUtils::getRealClass($organization))) {
             /** @var Organization $organization */
             $organization = $this->refreshEntity($organization);
             if ($organization) {
                 $token->setOrganizationContext($organization);
             }
         }
     }
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:33,代碼來源:RefreshContextListener.php

示例5: convertToExportFormat

 /**
  * {@inheritdoc}
  */
 public function convertToExportFormat(array $exportedRecord, $skipNullValues = true)
 {
     if ($this->context->getValue('columns')) {
         $columns = $this->context->getValue('columns');
     } elseif ($this->context->hasOption('gridName')) {
         $gridName = $this->context->getOption('gridName');
         $gridConfig = $this->gridManagerLink->getService()->getConfigurationForGrid($gridName);
         $columns = $gridConfig->offsetGet('columns');
     } else {
         throw new InvalidConfigurationException('Configuration of datagrid export processor must contain "gridName" or "columns" options.');
     }
     if ($this->context->hasOption('gridParameters')) {
         $gridParams = $this->context->getOption('gridParameters');
         if ($gridParams->has(ColumnsExtension::COLUMNS_PARAM)) {
             $columnsParams = $gridParams->get(ColumnsExtension::COLUMNS_PARAM);
             $columns = $this->columnsHelper->reorderColumns($columns, $columnsParams);
         }
     }
     $result = [];
     foreach ($columns as $columnName => $column) {
         if (isset($column['renderable']) && false === $column['renderable']) {
             continue;
         }
         $val = isset($exportedRecord[$columnName]) ? $exportedRecord[$columnName] : null;
         $val = $this->applyFrontendFormatting($val, $column);
         $result[$this->translator->trans($column['label'])] = $val;
     }
     return $result;
 }
開發者ID:sagikazarmark,項目名稱:platform,代碼行數:32,代碼來源:DatagridDataConverter.php

示例6: getUser

 /**
  * @param EntityManager $entityManager
  *
  * @return UserInterface|null
  */
 protected function getUser(EntityManager $entityManager)
 {
     $user = $this->securityFacadeLink->getService()->getLoggedUser();
     if ($user && $entityManager->getUnitOfWork()->getEntityState($user) == UnitOfWork::STATE_DETACHED) {
         $user = $entityManager->find('OroUserBundle:User', $user->getId());
     }
     return $user;
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:13,代碼來源:CommentLifecycleListener.php

示例7: isEnabled

 /**
  * {@inheritdoc}
  */
 public function isEnabled(Mailbox $mailbox = null)
 {
     if ($mailbox === null || null === ($organization = $mailbox->getOrganization())) {
         $organization = $this->securityLink->getService()->getOrganization();
     }
     $qb = $this->getChannelRepository()->createQueryBuilder('c');
     return (bool) $qb->select('COUNT(c.id)')->join('c.entities', 'e')->andWhere('e.name = :name')->andWhere('c.status = :status')->andWhere('c.owner = :owner')->setParameter('name', static::LEAD_CLASS)->setParameter('status', Channel::STATUS_ACTIVE)->setParameter('owner', $organization)->getQuery()->getSingleScalarResult();
 }
開發者ID:antrampa,項目名稱:crm,代碼行數:11,代碼來源:LeadMailboxProcessProvider.php

示例8: getNameDQL

 /**
  * {@inheritdoc}
  */
 public function getNameDQL($format, $locale, $className, $alias)
 {
     if ($format === self::FULL && $this->isFullFormatSupported($className)) {
         /** @var DQLNameFormatter $dqlNameFormatter */
         $dqlNameFormatter = $this->dqlNameFormatterLink->getService();
         return $dqlNameFormatter->getFormattedNameDQL($alias, $className, $locale);
     }
     return false;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:12,代碼來源:EntityNameProvider.php

示例9: preUpdate

 /**
  * @param PreUpdateEventArgs $eventArgs
  */
 public function preUpdate(PreUpdateEventArgs $eventArgs)
 {
     if ($eventArgs->getEntity() instanceof RoleInterface && $eventArgs->hasChangedField('role')) {
         $oldRoleName = $eventArgs->getOldValue('role');
         $newRoleName = $eventArgs->getNewValue('role');
         /** @var $aclSidManager AclSidManager */
         $aclSidManager = $this->aclSidManagerLink->getService();
         $aclSidManager->updateSid($aclSidManager->getSid($newRoleName), $oldRoleName);
     }
 }
開發者ID:nmallare,項目名稱:platform,代碼行數:13,代碼來源:RoleListener.php

示例10: checkPreAuth

 /**
  * {@inheritdoc}
  */
 public function checkPreAuth(UserInterface $user)
 {
     parent::checkPreAuth($user);
     if ($user instanceof User && null !== $this->securityContextLink->getService()->getToken() && null !== $user->getPasswordChangedAt() && null !== $user->getLastLogin() && $user->getPasswordChangedAt() > $user->getLastLogin()) {
         $this->flashBag->add('error', $this->translator->trans('oro.user.security.password_changed.message'));
         $exception = new PasswordChangedException('Invalid password.');
         $exception->setUser($user);
         throw $exception;
     }
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:13,代碼來源:UserChecker.php

示例11: getPackageManager

 /**
  * Set up specific environment for package manager
  *
  * @return PackageManager
  */
 protected function getPackageManager()
 {
     // avoid exception in Composer\Factory for creation service oro_distribution.composer
     if (!getenv('COMPOSER_HOME') && !getenv('HOME')) {
         putenv(sprintf('COMPOSER_HOME=%s', $this->composerCacheHome));
         // avoid change of current directory, just give correct vendor dir
         $rootPath = realpath($this->kernelRootDir . '/../') . DIRECTORY_SEPARATOR;
         Config::$defaultConfig['vendor-dir'] = $rootPath . Config::$defaultConfig['vendor-dir'];
     }
     return $this->pmLink->getService();
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:16,代碼來源:PackagesProvider.php

示例12: loadClassMetadata

 /**
  * @param LoadClassMetadataEventArgs $event
  */
 public function loadClassMetadata(LoadClassMetadataEventArgs $event)
 {
     $classMetadata = $event->getClassMetadata();
     $className = $classMetadata->getName();
     /** @var ExtendMetadataBuilder $metadataBuilder */
     $metadataBuilder = $this->metadataBuilderServiceLink->getService();
     if ($metadataBuilder->supports($className)) {
         $classMetadataBuilder = new ClassMetadataBuilder($classMetadata);
         $metadataBuilder->build($classMetadataBuilder, $className);
         $event->getEntityManager()->getMetadataFactory()->setMetadataFor($className, $classMetadata);
     }
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:15,代碼來源:DoctrineListener.php

示例13: onFlush

 /**
  * {@inheritdoc}
  */
 public function onFlush(OnFlushEventArgs $event)
 {
     // check for logged user is for confidence that data changes comes from UI, not from sync process.
     if ($this->securityFacadeLink->getService()->hasLoggedUser()) {
         $em = $event->getEntityManager();
         $this->processUpdates($em);
         $this->processDeletesAndCollections($em);
         while (null !== ($magentoCustomer = array_pop($this->processIds))) {
             $this->schedulerServiceLink->getService()->schedule($magentoCustomer->getChannel(), 'customer', ['id' => $magentoCustomer->getId()], false);
         }
     }
 }
開發者ID:dairdr,項目名稱:crm,代碼行數:15,代碼來源:ContactListener.php

示例14: getCriteriaByProvider

 /**
  * @param ActivityListProviderInterface $provider
  * @param $mapFields
  *
  * @return Criteria
  */
 protected function getCriteriaByProvider(ActivityListProviderInterface $provider, $mapFields)
 {
     $activityClass = $provider->getActivityClass();
     $aclClass = $provider->getAclClass();
     $criteria = new Criteria();
     $appliedCriteria = $this->aclHelper->applyAclToCriteria($aclClass, $criteria, 'VIEW', $mapFields);
     $isGranted = $this->securityContextLink->getService()->isGranted('VIEW', 'entity:' . $aclClass);
     if ($isGranted) {
         $appliedCriteria->andWhere(Criteria::expr()->eq('relatedActivityClass', $activityClass));
     }
     return $appliedCriteria;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:18,代碼來源:ActivityListAclCriteriaHelper.php

示例15: createGrid

 /**
  * @ActivityListQueryDesigner $queryDesigner
  *
  * @return DatagridInterface
  */
 public function createGrid(ActivityListQueryDesigner $source)
 {
     $this->datagridConfigurationBuilder->setGridName('related-activity');
     $this->datagridConfigurationBuilder->setSource($source);
     $config = $this->datagridConfigurationBuilder->getConfiguration();
     $stopPropagationListener = function (Event $e) {
         $e->stopPropagation();
     };
     $this->eventDispatcher->addListener(BuildBefore::NAME, $stopPropagationListener, 255);
     $grid = $this->gridBuilderLink->getService()->build($config, new ParameterBag());
     $this->eventDispatcher->removeListener(BuildBefore::NAME, $stopPropagationListener);
     return $grid;
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:18,代碼來源:DatagridHelper.php


注:本文中的Oro\Bundle\EntityConfigBundle\DependencyInjection\Utils\ServiceLink::getService方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。