本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectRepository::getClassName方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectRepository::getClassName方法的具体用法?PHP ObjectRepository::getClassName怎么用?PHP ObjectRepository::getClassName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\Common\Persistence\ObjectRepository
的用法示例。
在下文中一共展示了ObjectRepository::getClassName方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (!$value) {
return null;
}
if (null === ($entity = $this->repository->findOneBy(array($this->identifier => $value)))) {
throw new TransformationFailedException(sprintf('Object "%s" with identifier "%s"="%s" does not exist.', $this->repository->getClassName(), $this->identifier, $value));
}
return $entity;
}
示例2: reverseTransform
/**
* {@inheritdoc}
*/
public function reverseTransform($value)
{
if (null === $value) {
return '';
}
$class = $this->repository->getClassName();
if (!$value instanceof $class) {
throw new UnexpectedTypeException($value, $class);
}
$accessor = PropertyAccess::createPropertyAccessor();
return $accessor->getValue($value, $this->identifier);
}
示例3: createUserIdentity
public function createUserIdentity($user)
{
list($className, $identifier) = $this->extractUserIdentityFields($user);
if (isset($this->userCache[$className][$identifier])) {
return $this->userCache[$className][$identifier];
}
if (null !== ($this->userCache[$className][$identifier] = $this->userRepository->findOneBy(array('class' => $className, 'identifier' => $identifier)))) {
return $this->userCache[$className][$identifier];
}
$userClass = $this->userRepository->getClassName();
return $this->userCache[$className][$identifier] = new $userClass($className, $identifier);
}
示例4: createAce
/**
* Inserts a new ACE
*
* This method is idempotent.
*/
public function createAce($grantee, $target, $permission, $flush = true)
{
$grantee = $this->extractSecurityIdentity($grantee);
$target = $this->extractTargetIdentity($target);
if (!isset($this->writeCache[$grantee])) {
$this->writeCache[$grantee] = new \SplObjectStorage();
}
if (!isset($this->writeCache[$grantee][$target])) {
// Permissions are strings, no need for an SplObjectStorage.
$this->writeCache[$grantee][$target] = array();
}
$ace = null;
if (isset($this->writeCache[$grantee][$target][$permission])) {
$ace = $this->writeCache[$grantee][$target][$permission];
} else {
if (null !== $target->getId() && (null !== $grantee->getId() || SecurityIdentity::KIND_ANONYMOUS === $grantee->getKind())) {
// Both the target is persisted and the grantee is either
// persisted or anonymous. Let's see what the database has to
// say regarding this ACE.
$ace = $this->repository->findOneBy(array('grantee' => $this->generateCriteriaValue($grantee->getId()), 'target' => $this->generateCriteriaValue($target->getId()), 'permission' => $this->generateCriteriaValue($permission)));
}
if (null === $ace) {
$aceClass = $this->repository->getClassName();
$ace = $this->writeCache[$grantee][$target][$permission] = new $class($grantee, $target, $permission);
$this->om->persist($ace);
}
}
if ($flush) {
$this->om->flush();
}
return $ace;
}
示例5: getClassReflection
/**
* Get reflection of entity class
*
* @return \ReflectionClass
*/
protected function getClassReflection()
{
if ($this->reflection === null) {
$class = $this->repository->getClassName();
$this->reflection = new \ReflectionClass($class);
}
return $this->reflection;
}
示例6: create
/**
* {@inheritdoc}
*/
public function create(Utils\ArrayHash $values, Entities\IEntity $entity = NULL)
{
if (!$entity instanceof Entities\IEntity) {
$entityName = $this->entityRepository->getClassName();
$entity = $this->managerRegistry->getManagerForClass($entityName)->getClassMetadata($entityName)->newInstance();
}
if (!$entity || !$entity instanceof Entities\IEntity) {
throw new Exceptions\InvalidArgumentException('Entity could not be created.');
}
$this->processHooks($this->beforeCreate, [$entity, $values]);
$this->entityMapper->fillEntity($values, $entity, TRUE);
$entityManager = $this->managerRegistry->getManagerForClass(get_class($entity));
$entityManager->persist($entity);
$this->processHooks($this->afterCreate, [$entity, $values]);
if ($this->getFlush() === TRUE) {
$entityManager->flush();
}
return $entity;
}
示例7: createObjectFieldIdentity
public function createObjectFieldIdentity($object, $fieldName)
{
list($className, $identifier) = $this->extractObjectIdentityFields($object);
if (isset($this->objectFieldCache[$className][$identifier][$fieldName])) {
return $this->objectFieldCache[$className][$identifier][$fieldName];
}
if (null !== $object->getId() && null !== ($this->objectFieldCache[$className][$identifier][$fieldName] = $this->objectFieldRepository->findOneBy(array('object' => $object->getId(), 'fieldName' => $fieldName)))) {
return $this->objectFieldCache[$className][$identifier][$fieldName];
}
$objectFieldClass = $this->objectFieldRepository->getClassName();
return $this->objectFieldCache[$className][$identifier][$fieldName] = new $objectFieldClass($object, $fieldName, $this->createClassFieldIdentity($object->getClassName(), $field));
}
示例8:
function it_should_create_entity(ManagerRegistry $registry, EntityManager $em, ClassFactory $factory, ObjectRepository $repository, ClassMetadataInfo $class)
{
$entity = (object) ['foo' => null, 'bar' => null];
$class->getFieldNames()->willReturn(['id', 'foo', 'bar']);
$class->setFieldValue($entity, 'id', null)->shouldBeCalled();
$class->setFieldValue($entity, 'foo', 1)->shouldBeCalled();
$class->setFieldValue($entity, 'bar', 2)->shouldBeCalled();
$class->getAssociationNames()->willReturn([]);
$repository->getClassName()->willReturn('foo');
$factory->create('foo')->willReturn($entity);
$em->getRepository('foo')->willReturn($repository);
$em->getClassMetadata('foo')->willReturn($class);
$em->persist($entity)->shouldBeCalled();
$em->flush()->shouldBeCalled();
$registry->getManager(null)->willReturn($em);
$this->setRegistry($registry);
$this->setClassFactory($factory);
$entity->foo = 1;
$entity->bar = 2;
$this->create(['foo' => 1, 'bar' => 2])->shouldBe($entity);
}
示例9: let
function let(ObjectRepository $repository)
{
$repository->getClassName()->willReturn('spec\\Sylius\\Bundle\\ResourceBundle\\Form\\DataTransformer\\FakeEntity');
$this->beConstructedWith($repository, 'id');
}
示例10: __construct
public function __construct(ObjectRepository $repository)
{
$this->repository = $repository;
$this->class = $repository->getClassName();
}
示例11: configureOptions
/**
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
// We do not check if method exists because you may want to call a magic method
$methodName = $this->methodName;
$resolver->setDefaults(['choices' => call_user_func([$this->repository, $methodName]), 'class' => $this->repository->getClassName()]);
}
示例12: supportsClass
/**
* @param string $class
*
* @return bool
*/
public function supportsClass($class)
{
return $this->userRepository->getClassName() === $class || is_subclass_of($class, $this->userRepository->getClassName());
}
示例13: __construct
public function __construct(ObjectRepository $repository)
{
$this->repository = $repository;
parent::__construct($repository->getClassName());
}
示例14: __construct
public function __construct(ObjectManager $em, ObjectRepository $repository)
{
$this->em = $em;
$this->repository = $repository;
$this->reflClass = new \ReflectionClass($repository->getClassName());
}