本文整理汇总了PHP中Kdyby\Doctrine\EntityManager类的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager类的具体用法?PHP EntityManager怎么用?PHP EntityManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderDefault
public function renderDefault()
{
$this->template->anyVariable = 'any value';
// $dao = $this->articles;
$this->template->articles = $this->articles->getArticles()->findAll();
$posts = $this->EntityManager->getRepository(Posts::getClassName());
$this->template->posts = $posts->findAll();
$this->template->myparametr = $this->context->parameters['first_parametr'];
// $this->template->test = $this->doSomeRefactoring('Hello world from blog');
// $post = new Posts();
// $post->title = 'New title';
// $post->text = 'New text New textNew text';
// $post->created_at = new \Nette\Utils\DateTime;
//
//
// $this->EntityManager->persist($post);
// $this->EntityManager->flush();
// $dao = $this->EntityManager->getRepository(Posts::getClassName());
// $dao->setTitle('test');
// $dao->__call('set', ['title' => 'my title']);
// dump($dao->__isset('title'));
// $dao->__set('title', 'test');
try {
$this->checkNum(2);
\Tracy\Debugger::barDump('If you see this, the number is 1 or below');
} catch (Nette\Application\BadRequestException $e) {
Debugger::log('Message: ' . $e->getMessage());
var_dump($e->getMessage());
}
// finally {
// \Tracy\Debugger::barDump('Got here Finally');
// }
}
示例2: __construct
public function __construct(EntityManager $em)
{
$this->em = $em;
$this->streetRepository = $em->getRepository(Street::class);
$this->partCityRepository = $em->getRepository(PartCity::class);
$this->cityRepository = $em->getRepository(City::class);
}
示例3: __construct
public function __construct(EntityManager $entityManager, IAdminGridFactory $adminGridFactory, ITranslator $translator, RegistrationFormService $registrationFormService)
{
$this->registrationRepository = $entityManager->getRepository(Registration::class);
$this->adminGridFactory = $adminGridFactory;
$this->translator = $translator;
$this->registrationFormService = $registrationFormService;
}
示例4: __construct
/**
* @param EntityManager $entityManager
* @param Client $elastic
*/
public function __construct(EntityManager $entityManager, Client $elastic)
{
parent::__construct();
$this->entityManager = $entityManager;
$this->elastic = $elastic;
$this->seasonsRepository = $entityManager->getRepository(Season::class);
$this->languagesRepository = $entityManager->getRepository(Language::class);
}
示例5: __construct
public function __construct(EntityManager $entityManager, TagPersister $tagPersister, TagRemover $tagRemover, Logger $logger)
{
$this->em = $entityManager;
$this->tagPersister = $tagPersister;
$this->logger = $logger->channel('Tags');
$this->tagRepository = $this->em->getRepository(Tag::class);
$this->tagRemover = $tagRemover;
}
示例6: getLastPosition
private function getLastPosition(EntityManager $em)
{
$last = $em->getRepository(get_class($this))->findOneBy([], ["position" => "DESC"]);
if ($last) {
return $last->getPosition();
}
return 0;
}
示例7: __construct
public function __construct(ImagesUploader $imagesUploader, ImagesRemover $imagesRemover, EntityManager $entityManager, Logger $logger)
{
$this->imagesUploader = $imagesUploader;
$this->imagesRemover = $imagesRemover;
$this->em = $entityManager;
$this->logger = $logger->channel('images');
$this->imageRepository = $this->em->getRepository(Image::class);
}
示例8: createBasicQuery
private function createBasicQuery(Kdyby\Doctrine\EntityManager $entityManager)
{
$qb = $entityManager->createQueryBuilder();
$qb->from(Comment::class, 'c');
foreach ($this->filter as $modifier) {
$modifier($qb);
}
return $qb;
}
示例9: __construct
public function __construct(\Kdyby\Doctrine\EntityManager $entityManager)
{
if (!$this->table_name) {
throw new \Exception('Variable $db_nam must be filled!');
}
$this->em = $entityManager;
$entits = new $this->table_name();
$this->entit = $this->em->getRepository($entits);
}
示例10: isEntity
/**
* Check object status is enity
*
* @param object|string $entity
* @return bool
*/
protected function isEntity($entity)
{
if (is_object($entity)) {
$entity = ClassUtils::getClass($entity);
}
return !$this->entityManager->getMetadataFactory()->isTransient($entity);
}
示例11: findEventsByType
public function findEventsByType($logTypeID)
{
return $this->cache->load('logEvents-' . $logTypeID, function (&$dependencies) use($logTypeID) {
return array_column($this->em->createQuery('SELECT e.id, e.name FROM ' . EventLog::class . ' e INDEX BY e.id
WHERE e.logType = :typeID')->setParameter('typeID', $logTypeID)->getArrayResult(), 'name', 'id');
});
}
示例12: assignAlbums
/**
* @param User $user
* @param array $albums
*/
public function assignAlbums(User $user, array $albums)
{
$user->albums->clear();
$user->setAlbums($albums);
$this->em->persist($user);
$this->em->flush();
}
示例13: initialize
public function initialize(IIdentity $identity)
{
if ($identity instanceof EntityIdentity && !$identity->isLoaded()) {
$identity->load($this->em->getDao($identity->getEntityClass()));
}
return $identity;
}
示例14: createComponentGrid
protected function createComponentGrid($name)
{
$grid = new Grid($this, $name);
$repository = $this->database->getRepository('App\\Models\\Doctrine\\Entities\\User');
$model = new \Grido\DataSources\Doctrine($repository->createQueryBuilder('a')->addSelect('c')->innerJoin('a.country', 'c'), array('country' => 'c.title'));
// Map country column to the title of the Country entity
$grid->model = $model;
$grid->addColumnText('firstname', 'Firstname')->setFilterText()->setSuggestion();
$grid->addColumnText('surname', 'Surname')->setSortable()->setFilterText()->setSuggestion();
$grid->addColumnText('gender', 'Gender')->setSortable()->cellPrototype->class[] = 'center';
$grid->addColumnDate('birthday', 'Birthday', \Grido\Components\Columns\Date::FORMAT_TEXT)->setSortable()->setFilterDate()->setCondition($grid->birthdayFilterCondition);
$grid->getColumn('birthday')->cellPrototype->class[] = 'center';
$grid->addColumnText('country', 'Country')->setSortable()->setCustomRender(function ($item) {
$baseUri = $this->getBaseUri();
$img = Html::el('img')->src("{$baseUri}/img/flags/{$item->country_code}.gif");
return "{$img} {$item->country}";
})->setFilterText()->setSuggestion();
$grid->addColumnText('card', 'Card')->setSortable()->setColumn('cctype')->setReplacement(array('MasterCard' => Html::el('b')->setText('MasterCard')))->cellPrototype->class[] = 'center';
$grid->addColumnEmail('emailaddress', 'Email')->setSortable()->setFilterText();
$grid->getColumn('emailaddress')->cellPrototype->class[] = 'center';
$grid->addColumnText('centimeters', 'Height')->setSortable()->setFilterNumber();
$grid->getColumn('centimeters')->cellPrototype->class[] = 'center';
$grid->addFilterSelect('gender', 'Gender', array('' => '', 'female' => 'female', 'male' => 'male'));
$grid->addFilterSelect('card', 'Card', array('' => '', 'MasterCard' => 'MasterCard', 'Visa' => 'Visa'))->setColumn('cctype');
$grid->addFilterCheck('preferred', 'Only preferred girls :)')->setCondition(array(TRUE => array(array('gender', 'AND', 'centimeters'), array('= ?', '>= ?'), array('female', 170))));
$grid->addActionHref('edit', 'Edit')->setIcon('pencil');
$grid->addActionHref('delete', 'Delete')->setIcon('trash')->setConfirm(function ($item) {
return "Are you sure you want to delete {$item->firstname} {$item->surname}?";
});
$operation = array('print' => 'Print', 'delete' => 'Delete');
$grid->setOperation($operation, $this->handleOperations)->setConfirm('delete', 'Are you sure you want to delete %i items?');
$grid->filterRenderType = $this->filterRenderType;
$grid->setExport();
}
示例15: addDefinition
/**
* @param Privilege $privilege
* @param Role $role
* @return $this
*/
public function addDefinition(Privilege $privilege, Role $role)
{
$accessDefinition = new AccessDefinition($this->resource, $privilege);
$this->em->persist($accessDefinition);
$permission = new Permission($role, $this->resource, $privilege);
$this->em->persist($permission);
return $this;
}