本文整理汇总了PHP中Doctrine\Common\Persistence\ObjectRepository类的典型用法代码示例。如果您正苦于以下问题:PHP ObjectRepository类的具体用法?PHP ObjectRepository怎么用?PHP ObjectRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Place
function it_converts_node_to_street_entry_with_updating_existing_one(ObjectManager $om, ObjectRepository $or, Street $street)
{
$xml = <<<EOT
<row>
<col name="WOJ">02</col>
<col name="POW">23</col>
<col name="GMI">09</col>
<col name="RODZ_GMI">2</col>
<col name="SYM">0884849</col>
<col name="SYM_UL">10268</col>
<col name="CECHA">ul.</col>
<col name="NAZWA_1">Księżycowa </col>
<col name="NAZWA_2"/>
<col name="STAN_NA">2013-10-10</col>
</row>
EOT;
$place = new Place(884849);
$place->setName('City');
$or->findOneBy(array('id' => '0884849'))->shouldBeCalled()->willReturn($place);
$or->findOneBy(array('id' => '10268', 'place' => $place))->shouldBeCalled()->willReturn($street);
$street->setName('Księżycowa')->shouldBeCalled()->willReturn($street);
$street->setAdditionalName('')->shouldBeCalled()->willReturn($street);
$street->setType('ul.')->shouldBeCalled()->willReturn($street);
$this->beConstructedWith(new \SimpleXMLElement($xml), $om);
$this->convertToEntity()->shouldBeLike($street->getWrappedObject());
}
示例2: array
function it_does_reverse_transform_identifiers_to_array_of_entities(ObjectRepository $repository, FakeEntity $entityOne, FakeEntity $entityTwo)
{
$value = array(1, 2);
$entityOne->getId()->willReturn(1);
$entityTwo->getId()->willReturn(2);
$repository->findBy(array('id' => $value))->shouldBeCalled()->willReturn(array($entityOne, $entityTwo));
$this->reverseTransform($value)->shouldReturn(array($entityOne, $entityTwo));
}
示例3: createAddress
/**
* @param $data
* @return AbstractDefaultTypedAddress
*/
protected function createAddress($data)
{
/** @var Country $country */
$country = $this->countryRepository->findOneBy(['iso2Code' => $data['country']]);
if (!$country) {
throw new \RuntimeException('Can\'t find country with ISO ' . $data['country']);
}
/** @var Region $region */
$region = $this->regionRepository->findOneBy(['country' => $country, 'code' => $data['state']]);
if (!$region) {
throw new \RuntimeException(printf('Can\'t find region with country ISO %s and code %s', $data['country'], $data['state']));
}
$types = [];
$typesFromData = explode(',', $data['types']);
foreach ($typesFromData as $type) {
$types[] = $this->addressTypeRepository->find($type);
}
$defaultTypes = [];
$defaultTypesFromData = explode(',', $data['defaultTypes']);
foreach ($defaultTypesFromData as $defaultType) {
$defaultTypes[] = $this->addressTypeRepository->find($defaultType);
}
$address = $this->getNewAddressEntity();
$address->setTypes(new ArrayCollection($types));
$address->setDefaults(new ArrayCollection($defaultTypes))->setPrimary(true)->setLabel('Primary address')->setCountry($country)->setStreet($data['street'])->setCity($data['city'])->setRegion($region)->setPostalCode($data['zipCode']);
return $address;
}
示例4: getRoles
/**
* {@inheritDoc}
*/
public function getRoles()
{
$result = $this->objectRepository->findAll();
$roles = array();
// Pass One: Build each object
foreach ($result as $role) {
if (!$role instanceof RoleInterface) {
continue;
}
$roleId = $role->getRoleId();
$parent = null;
if ($role instanceof HierarchicalRoleInterface && ($parent = $role->getParent())) {
$parent = $parent->getRoleId();
}
$roles[$roleId] = new Role($roleId, $parent);
}
// Pass Two: Re-inject parent objects to preserve hierarchy
/* @var $roleObj \BjyAuthorize\Acl\Role */
foreach ($roles as $roleObj) {
$parentRoleObj = $roleObj->getParent();
if ($parentRoleObj && $parentRoleObj->getRoleId()) {
$roleObj->setParent($roles[$parentRoleObj->getRoleId()]);
}
}
return array_values($roles);
}
示例5: getRules
/**
* Here we read rules from DB and put them into a form that BjyAuthorize's Controller.php understands
*/
public function getRules()
{
$rules = array();
// initialize the rules array
//
// get the doctrine shemaManager
$schemaManager = $this->objectManager->getConnection()->getSchemaManager();
// check if the roles table exists, if it does not, do not bother querying
if ($schemaManager->tablesExist(array('roles')) === true) {
//read from object store a set of (role, controller, action)
$result = $this->objectRepository->findAll();
// if a result set exists
if (count($result)) {
//transform to object BjyAuthorize will understand
foreach ($result as $key => $role) {
$roleId = $role->getRoleId();
// check if any resource access has been defined before
// if it has, continue with normal operations
// else, allow access to this first user
if (!$role->getResources()) {
continue;
}
foreach ($role->getResources() as $rle) {
$this->defaultRules['allow'][] = [[$roleId], $rle->getControllerId(), []];
}
}
}
}
return $this->defaultRules;
}
示例6: buildAdminEntity
protected function buildAdminEntity($value, Toponym $toponym)
{
/* @var $admin \Giosh94mhz\GeonamesBundle\Entity\Admin1 */
$admin = $this->repository->find($toponym) ?: new Admin1($toponym);
$admin->setCode($value[5])->setCountryCode($value[4])->setName($value[1])->setAsciiName($value[2]);
return $admin;
}
示例7: checkDuplicity
private function checkDuplicity(Category $category)
{
$duplicate = $this->repository->findOneBy(['path' => $category->getPath()]);
if ($duplicate !== null) {
throw new EntityDuplicateException(sprintf('Category with path %s already exists.', $category->getPath()));
}
}
示例8: loadChoiceList
/**
* {@inheritdoc}
*/
public function loadChoiceList($value = null)
{
if ($this->choiceList) {
return $this->choiceList;
}
return $this->choiceList = $this->factory->createListFromChoices($this->repository->findAll(), $value);
}
示例9: testFindSchedules
public function testFindSchedules()
{
$limit = 2;
$offset = 1;
$this->repository->expects($this->once())->method('findBy')->with(array(), array(), $limit, $offset);
$this->subject->findSchedules($limit, $offset);
}
示例10: buildEntity
public function buildEntity($value)
{
$parent = null;
$child = null;
try {
/* @var $parent \Giosh94mhz\GeonamesBundle\Entity\Toponym */
$parent = $this->toponymRepository->find($value[0]);
/* @var $child \Giosh94mhz\GeonamesBundle\Entity\Toponym */
$child = $this->toponymRepository->find($value[1]);
if (!$parent || !$child) {
throw new MissingToponymException("HierarchyLink not imported due to missing toponym '{$value['0']}=>{$value['1']}'");
}
/* @var $link \Giosh94mhz\GeonamesBundle\Entity\HierarchyLink */
$link = $this->repository->find(array('parent' => $parent->getId(), 'child' => $child->getId())) ?: new HierarchyLink($parent, $child);
$link->setType($value[2]);
return $link;
} catch (\Exception $e) {
if ($parent !== null) {
$this->om->detach($parent);
}
if ($child !== null) {
$this->om->detach($child);
}
throw $e;
}
}
示例11: testFindWithInvalidObject
/**
* @expectedException \Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException
*/
public function testFindWithInvalidObject()
{
$this->loader->expects($this->atLeastOnce())->method('mapPathToId')->with('/foo/bar')->will($this->returnValue(1337));
$this->loader->expects($this->never())->method('getStreamFromImage');
$this->om->expects($this->atLeastOnce())->method('find')->with(null, 1337)->will($this->returnValue(null));
$this->loader->find('/foo/bar');
}
示例12: get
/**
* @param string $paymentMethod
*
* @return array
*/
public function get($paymentMethod)
{
if (!isset($this->settings[$paymentMethod])) {
$this->settings[$paymentMethod] = $this->repository->getSettingsForMethodArray($paymentMethod);
}
return $this->settings[$paymentMethod];
}
示例13: get
/**
* @{inheritdoc}
*/
public function get($id = null)
{
if (null !== $id) {
return $this->repository->find($id);
}
return $this->repository->findAll();
}
示例14: tryGetMRByCode
/**
* Try to get from local property if exist or load from database afterwards
*
* @param string $code
*
* @return Region|Null
*/
protected function tryGetMRByCode($code)
{
if (!isset($this->MRIdentityMap[$code]) && !array_key_exists($code, $this->MRIdentityMap)) {
$this->MRIdentityMap[$code] = $this->repository->findOneBy(['combinedCode' => $code]);
}
return $this->MRIdentityMap[$code];
}
示例15: get
/**
* @{inheritdoc}
*/
public function get($id = null)
{
if (null !== $id) {
return $this->repository->find($id);
}
return $this->manager->findUsers();
}