本文整理汇总了PHP中Kdyby\Doctrine\EntityManager::getDao方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::getDao方法的具体用法?PHP EntityManager::getDao怎么用?PHP EntityManager::getDao使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kdyby\Doctrine\EntityManager
的用法示例。
在下文中一共展示了EntityManager::getDao方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize(IIdentity $identity)
{
if ($identity instanceof EntityIdentity && !$identity->isLoaded()) {
$identity->load($this->em->getDao($identity->getEntityClass()));
}
return $identity;
}
示例2: handle
public function handle($name, array $options, ClassMetadata $classMetadata, Configuration $configuration)
{
if (!empty($options['control'])) {
return NULL;
}
if (!($mapping = MetadataHelpers::getAssociationMapping($classMetadata, $name, ClassMetadata::ONE_TO_ONE))) {
return NULL;
}
$targetMetadata = $this->entityManager->getDao($mapping['targetEntity'])->getClassMetadata();
return new ContainerBuilder($targetMetadata, new Container(), $configuration);
}
示例3: getEvent
/**
* Get event
* @param integer $eventId
* @return Event
*/
public function getEvent($eventId)
{
// Má právo na editaci? (výchozí: ano)
$canAccess = FALSE;
$hasAccess = FALSE;
$hasShare = FALSE;
/** @var null|Event $event */
$event = $this->eventDao->find($eventId);
if ($event->isDeleted()) {
throw new Nette\Application\BadRequestException($this->translator->translate('event.general.noId'));
}
// Is this api call?
if ($this->user->getId() === 0) {
$canAccess = TRUE;
} else {
/** @var \App\Model\Entity\User $userEntity */
$userEntity = $this->em->getDao('\\App\\Model\\Entity\\User')->find($this->user->getId());
/** @var \App\Model\Entity\Client $client */
$client = $userEntity->getClient();
// je uživatel ADMIN?
if (($this->user->isInRole('ADMIN') || $this->user->isInRole('ACCOUNTANT')) && $this->isClientsEvent($event, $client)) {
$canAccess = TRUE;
} elseif (($this->user->isInRole('USER') || $this->user->isInRole('ACCOUNTANT')) && $this->isClientsEvent($event, $client)) {
//požadavek klienta, aby šel
$canAccess = TRUE;
} else {
// pokud nemá přiřazené oprávnění, má přidělené sdílení?
if ($event->getShares() !== NULL) {
$hasShare = FALSE;
foreach ($event->getShares() as $clientShare) {
if ($client->getId() == $clientShare->getClient()->getId()) {
$hasShare = TRUE;
break;
}
}
}
// pokud ano, má přiřazená oprávnění pro event?
if ($event->getAccesses() !== NULL) {
foreach ($event->getAccesses() as $clientAccess) {
$hasAccess = FALSE;
if ($client->getId() == $clientAccess->getReceiver()->getId() || $client->getId() == $clientAccess->getCreator()->getId()) {
$hasAccess = TRUE;
break;
}
}
}
// pokud ne, patří událost klientovi nebo sdílení, anebo přístup?
if ($hasAccess || $hasShare) {
$canAccess = TRUE;
}
}
}
if ($canAccess) {
// má přístup do události?
return $event;
} else {
// jinak je přesměrován na dashboard s tím, že je upozorněn na to, že nemá oprávnění
throw new Nette\Application\ForbiddenRequestException($this->translator->translate('event.general.noRights'));
}
}
示例4: handle
public function handle($name, array $options, ClassMetadata $classMetadata, Configuration $configuration)
{
if (!($mapping = MetadataHelpers::getAssociationMapping($classMetadata, $name, ClassMetadata::ONE_TO_MANY))) {
return NULL;
}
$options += ['createDefault' => 0];
$dao = $this->entityManager->getDao($mapping['targetEntity']);
$containerPrototype = new Container();
$replicator = new ClonnableReplicator(function (Container $container) use($containerPrototype) {
$clone = function (Container $targetContainer, Container $sourceContainer) use(&$clone) {
/** @var IComponent $component */
foreach ($sourceContainer->getComponents() as $component) {
if ($component instanceof Container && !$component instanceof ClonnableReplicator) {
/** @var Container $component */
$container = new Container();
$container->setCurrentGroup($component->getCurrentGroup());
$container->onValidate = $component->onValidate;
$targetContainer[$component->getName()] = $container;
$clone($container, $component);
} else {
$targetContainer[$component->getName()] = $control = clone $component;
if ($control instanceof BaseControl) {
$clonner = function () {
/** @var BaseControl $this */
$this->control = clone $this->control;
$this->label = clone $this->label;
};
$clonner = $clonner->bindTo($control, $control);
$clonner();
}
}
}
};
$clone($container, $containerPrototype);
}, $options['createDefault']);
return new ReplicatorBuilder($dao->getClassMetadata(), $replicator, $configuration, $containerPrototype);
}
示例5: create
/**
* @param $entityName
* @param EntityManager $entityManager
* @return \Kdyby\Doctrine\EntityDao
*/
public static function create($entityName, EntityManager $entityManager)
{
return $entityManager->getDao($entityName);
}
示例6: fetchPairs
/**
* @param Relation $relation
* @param $entityName
* @return array
*/
public function fetchPairs(Relation $relation, $entityName)
{
$criteria = array();
return $this->entityManager->getDao($entityName)->findPairs($criteria, $relation->getSelectedBy());
}