本文整理汇总了PHP中Doctrine\ORM\Event\LifecycleEventArgs::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP LifecycleEventArgs::getEntity方法的具体用法?PHP LifecycleEventArgs::getEntity怎么用?PHP LifecycleEventArgs::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Event\LifecycleEventArgs
的用法示例。
在下文中一共展示了LifecycleEventArgs::getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postLoad
/**
* After WorkflowItem loaded, de-serialize WorkflowItem
*
* @param LifecycleEventArgs $args
*/
public function postLoad(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($this->isSupported($args->getEntity($entity))) {
$this->deserialize($entity);
}
}
示例2: preSave
/**
* Handle pre save event
*
* @param LifecycleEventArgs $args Event arguments
*/
protected function preSave(LifecycleEventArgs $args)
{
$annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
if (0 === count($annotations)) {
return;
}
foreach ($annotations as $field => $annotation) {
$config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
continue;
}
$value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
$value = array_filter($value, 'strlen');
$value = array_map(function ($file) {
return pathinfo($file, PATHINFO_BASENAME);
}, $value);
if (empty($value)) {
continue;
}
$orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
$files = [];
foreach ($orphanageStorage->getFiles() as $file) {
if (in_array($file->getBasename(), $value, true)) {
$files[] = $file;
}
}
$orphanageStorage->uploadFiles($files);
}
}
示例3: preRemove
public function preRemove(LifecycleEventArgs $args)
{
if ($args->getEntity() instanceof Appearance) {
$appearance = $args->getEntity();
$appearance->setPlayer(null);
$appearance->setGame(null);
}
}
示例4: postLoad
public function postLoad(LifecycleEventArgs $event)
{
if ($event->getEntity() instanceof Repository) {
$event->getEntity()->init($this->container);
}
if ($event->getEntity() instanceof StoredFile) {
$event->getEntity()->init($this->container);
}
}
示例5: postLoad
public function postLoad(LifecycleEventArgs $event)
{
if ($event->getEntity() instanceof PartAttachment) {
/**
* @var $entity PartAttachment
*/
$entity = $event->getEntity();
$entity->setImage($this->imageService->canHandleMimetype($entity->getMimeType()));
}
}
示例6: postRemove
/**
* @param LifecycleEventArgs $eventArgs
* @return void
*/
public function postRemove(LifecycleEventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof ImageInterface) {
/** @var PersistentResource $resource */
$resource = $eventArgs->getEntity()->getResource();
if ($resource !== null) {
$this->cacheManager->getCache('TYPO3_Media_ImageSize')->remove($resource->getCacheEntryIdentifier());
}
}
}
示例7: flush
protected function flush(LifecycleEventArgs $args)
{
$identifier = $this->collectionIdentifiers->getIdentifier($args->getEntity());
if ($identifier === false) {
return;
}
$parameters = array(get_class($args->getEntity()) => $identifier);
foreach ($this->caches as $cache) {
$cache->flush($parameters);
}
}
示例8: preRemove
/**
* When element answers are deleted they need to notify thier jazzee elements
*
* @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
*/
public function preRemove(\Doctrine\ORM\Event\LifecycleEventArgs $eventArgs)
{
switch (get_class($eventArgs->getEntity())) {
case 'Jazzee\\Entity\\Answer':
$answer = $eventArgs->getEntity();
foreach ($answer->getElementAnswers() as $elementAnswer) {
$elementAnswer->preRemove();
}
if ($attachment = $answer->getAttachment()) {
$attachment->preRemove();
}
break;
}
}
示例9: update
/**
* @param LifecycleEventArgs $args
* @param bool $remove
*/
protected function update(LifecycleEventArgs $args, $remove)
{
$alias = $this->builder->getEntityAlias($args->getEntity());
$this->keeper->set($alias, new \DateTime());
if ($this->track_individually_entity) {
$ids = $this->builder->getEntityIdentifier($args->getEntity());
if ($ids !== null) {
if ($remove) {
$this->keeper->remove($alias . $ids);
} else {
$this->keeper->set($alias . $ids, new \DateTime());
}
}
}
}
示例10: prePersist
public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof Layout) {
$entity->setEngine($this->engineParameter);
}
}
示例11: prePersist
public function prePersist(LifecycleEventArgs $args)
{
$entity = $args->getEntity();
if ($entity instanceof User) {
$this->handleEvent($entity);
}
}
示例12:
function it_canonicalize_only_user_or_customer_interface_implementation_on_pre_update($canonicalizer, LifecycleEventArgs $event)
{
$item = new \stdClass();
$event->getEntity()->willReturn($item);
$canonicalizer->canonicalize(Argument::any())->shouldNotBeCalled();
$this->preUpdate($event);
}
示例13:
function it_updates_password_on_pre_update_doctrine_event_for_user_interface_implementation_only($passwordUpdater, LifecycleEventArgs $event, UserInterface $user)
{
$user = '';
$event->getEntity()->willReturn($user);
$passwordUpdater->updatePassword($user)->shouldNotBeCalled();
$this->preUpdate($event);
}
示例14: postLoad
/**
* @param LifecycleEventArgs $event
*/
public function postLoad(LifecycleEventArgs $event)
{
$entity = $event->getEntity();
if ($entity instanceof ConfigurationEntry) {
$entity->init($this->container);
}
}
示例15: postLoad
public function postLoad(LifecycleEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
$entity = $eventArgs->getEntity();
$classname = get_class($entity);
if (!array_key_exists($classname, $this->getEntities())) {
return null;
}
/** @var Schema $schema */
$schema = $em->getRepository('Padam87AttributeBundle:Schema')->findOneBy(array('className' => $classname));
if ($schema === null) {
throw new \UnexpectedValueException('Schema not found for ' . $classname);
}
$qb = $em->getRepository($classname)->createQueryBuilder('main');
$qb->distinct()->select('d.id')->join('main.attributes', 'a')->join('a.definition', 'd', null, null, 'd.id')->where('main = :main')->setParameter('main', $entity);
$definitions = $qb->getQuery()->getScalarResult();
$ids = array_map('current', $definitions);
foreach ($schema->getDefinitions() as $definition) {
if (!in_array($definition->getId(), $ids)) {
$attribute = new Attribute();
$attribute->setDefinition($definition);
$entity->addAttribute($attribute);
}
}
if ($uow->getEntityState($entity) == UnitOfWork::STATE_MANAGED) {
$em->persist($entity);
$em->flush($entity);
}
}