本文整理汇总了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);
}
示例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();
}
示例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()]);
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}