本文整理汇总了PHP中ORM::entityManager方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::entityManager方法的具体用法?PHP ORM::entityManager怎么用?PHP ORM::entityManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::entityManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(ActionInterface $action)
{
// Grab the target item for the page's page type.
$subject = $action->getSubject();
$target = $action->getTarget();
$areaMapper = new Area();
$targetItemList = new TargetItemList($target->getBatch(), $areaMapper);
foreach ($subject->getAreas() as $area) {
$item = new Item($area->getName());
$targetItem = $targetItemList->getSelectedTargetItem($item);
if ($targetItem instanceof UnmappedTargetItem) {
$template = $subject->getTemplate();
// Now, if the page template exists in the batch, there's a chance that the reason the area
// doesn't exist in the site is because it's part of the new template. In that case, we should show
// an info message so we don't get as many scary red errors.
if ($template) {
$em = \ORM::entityManager('migration_tool');
$r = $em->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\PageTemplate');
$batchTemplate = $r->findOneByHandle($template);
}
if (isset($batchTemplate) && is_object($batchTemplate)) {
$action->getTarget()->addMessage(new Message(t('Area <strong>%s</strong> does not exist in site. If the area is page of the new page template this message can be disregarded.', $item->getIdentifier()), Message::E_INFO));
} else {
$action->getTarget()->addMessage(new Message(t('Area <strong>%s</strong> does not exist.', $item->getIdentifier())));
}
}
}
}
示例2: installBlockType
/**
* Installs a BlockType that is passed via a btHandle string. The core or override directories are parsed.
*/
public static function installBlockType($btHandle, $pkg = false)
{
$env = Environment::get();
$pkgHandle = false;
if (is_object($pkg)) {
$pkgHandle = $pkg->getPackageHandle();
}
$class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
$app = Facade::getFacadeApplication();
$bta = $app->build($class);
$path = dirname($env->getPath(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB, $pkgHandle));
//Attempt to run the subclass methods (install schema from db.xml, etc.)
$r = $bta->install($path);
// Prevent the database records being stored in wrong language
$loc = Localization::getInstance();
$loc->pushActiveContext('system');
//Install the block
$bt = new \Concrete\Core\Entity\Block\BlockType\BlockType();
$bt->loadFromController($bta);
if (is_object($pkg)) {
$bt->setPackageID($pkg->getPackageID());
}
$bt->setBlockTypeHandle($btHandle);
$loc->popActiveContext();
$em = \ORM::entityManager();
$em->persist($bt);
$em->flush();
if ($bta->getBlockTypeDefaultSet()) {
$set = Set::getByHandle($bta->getBlockTypeDefaultSet());
if (is_object($set)) {
$set->addBlockType($bt);
}
}
return $bt;
}
示例3: transform
public function transform($entity, ItemInterface $item, TargetItem $targetItem, Batch $batch)
{
$mapper = new \PortlandLabs\Concrete5\MigrationTool\Batch\ContentMapper\Type\Attribute();
$ak = $mapper->getTargetItemContentObject($targetItem);
if (is_object($ak)) {
$type = $ak->getAttributeKeyType()->getAttributeTypeHandle();
} else {
$collection = $batch->getObjectCollection('attribute_key');
foreach ($collection->getKeys() as $key) {
if ($key->getHandle() == $item->getIdentifier()) {
$type = $key->getType();
break;
}
}
}
if (isset($type)) {
$manager = \Core::make('migration/manager/import/attribute/value');
try {
$driver = $manager->driver($type);
} catch (\Exception $e) {
}
if (isset($driver)) {
$xml = simplexml_load_string($entity->getValue());
$value = $driver->parse($xml);
$attribute = $entity->getAttribute();
$attribute->setAttributeValue($value);
$manager = \ORM::entityManager('migration_tools');
$manager->persist($attribute);
$manager->remove($entity);
$manager->flush();
}
}
}
示例4: displayObjectCollection
public function displayObjectCollection()
{
$em = \ORM::entityManager('migration_tool');
$r = $em->getRepository("\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\Batch");
$batch = $r->findFromCollection($this->collection);
print \View::element('batch_content_types/' . $this->getElement(), array('batch' => $batch, 'type' => $this->collection->getType(), 'collection' => $this->collection), 'migration_tool');
}
示例5: __construct
public function __construct(ObjectCollection $collection)
{
$em = \ORM::entityManager('migration_tool');
$r = $em->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\Batch');
$this->collection = $collection;
$this->batch = $r->findFromCollection($collection);
$this->validator = $collection->getRecordValidator($this->batch);
}
示例6: view
public function view()
{
$r = \ORM::entityManager()->getRepository('\\Concrete\\Core\\Entity\\Express\\Entity');
$entities = $r->findAll(array(), array('name' => 'asc'));
$this->set('types', $entities);
$this->set('currentType', $this->currentEntity);
$this->set('entityAction', $this->entityAction);
}
示例7: add
public static function add($filename, $prefix, $data = array(), $fsl = false, $folder = false)
{
$db = Loader::db();
$dh = Loader::helper('date');
$date = $dh->getOverridableNow();
if (!is_object($fsl)) {
$fsl = StorageLocation::getDefault();
}
$uID = 0;
$u = new User();
if (isset($data['uID'])) {
$uID = $data['uID'];
} else {
if ($u->isRegistered()) {
$uID = $u->getUserID();
}
}
if (!$folder instanceof FileFolder) {
$filesystem = new Filesystem();
$folder = $filesystem->getRootFolder();
}
$f = new \Concrete\Core\Entity\File\File();
$f->storageLocation = $fsl;
$f->fDateAdded = new Carbon($date);
$f->folderTreeNodeID = $folder->getTreeNodeID();
$em = \ORM::entityManager();
$em->persist($f);
$em->flush();
if ($uID > 0) {
$ui = UserInfo::getByID($uID);
if (is_object($ui)) {
$ue = $ui->getEntityObject();
if (is_object($ue)) {
$f->setUser($ue);
}
}
}
$node = \Concrete\Core\Tree\Node\Type\File::add($f, $folder);
$fv = Version::add($f, $filename, $prefix, $data);
$f->versions->add($fv);
$fve = new \Concrete\Core\File\Event\FileVersion($fv);
Events::dispatch('on_file_add', $fve);
$entities = $u->getUserAccessEntityObjects();
$hasUploader = false;
foreach ($entities as $obj) {
if ($obj instanceof FileUploaderPermissionAccessEntity) {
$hasUploader = true;
}
}
if (!$hasUploader) {
$u->refreshUserGroups();
}
return $fv;
}
示例8: finish
public function finish(ActionInterface $action)
{
$entityManager = \ORM::entityManager();
$target = $action->getTarget();
$pl = 0;
$n = count($this->paths);
$l = strlen($this->paths[0]);
while ($pl < $l) {
$c = $this->paths[0][$pl];
for ($i = 1; $i < $n; ++$i) {
if ($this->paths[$i][$pl] !== $c) {
break 2;
}
}
++$pl;
}
$common = substr($this->paths[0], 0, $pl);
$pages = $target->getBatch()->getPages();
// $entityManager->getConnection()->getConfiguration()->setSQLLogger(new EchoSQLLogger());
if ($common && count($pages) > 1) {
$common = '/' . trim($common, '/');
$contentSearchURL = "/\\{ccm:export:page:" . preg_quote($common, '/') . "(.*?)\\}/i";
$contentReplaceURL = "{ccm:export:page:\$1}";
foreach ($pages as $page) {
$originalPath = $page->getOriginalPath();
$newPath = substr($originalPath, strlen($common));
if ($page->canNormalizePath()) {
$page->setBatchPath($newPath);
}
$areas = $page->getAreas();
foreach ($areas as $area) {
$blocks = $area->getBlocks();
foreach ($blocks as $block) {
$value = $block->getBlockValue();
if ($value instanceof ImportedBlockValue) {
$content = preg_replace($contentSearchURL, $contentReplaceURL, $value->getValue());
$query = $entityManager->createQuery("update \\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\BlockValue\\ImportedBlockValue v\n set v.value = :value where v.id = :primary");
$query->setParameter('primary', $value->getID());
$query->setParameter('value', $content);
$query->execute();
}
}
}
}
} else {
foreach ($pages as $page) {
if ($page->canNormalizePath()) {
$page->setBatchPath($page->getOriginalPath());
}
}
}
}
示例9: execute
public function execute(ActionInterface $action)
{
$blocks = $action->getSubject();
$target = $action->getTarget();
$mapper = new \PortlandLabs\Concrete5\MigrationTool\Batch\ContentMapper\Type\BlockType();
$targetItemList = new TargetItemList($target->getBatch(), $mapper);
foreach ($blocks as $block) {
if ($block->getType()) {
$item = new BlockItem($block);
$targetItem = $targetItemList->getSelectedTargetItem($item);
if ($targetItem instanceof UnmappedTargetItem) {
$action->getTarget()->addMessage(new Message(t('Block type <strong>%s</strong> does not exist.', $item->getIdentifier())));
}
} elseif ($block->getDefaultsOutputIdentifier()) {
// This is a block on a page that is pulling its content from page defaults. We need to find
// a block with the corresponding string in page defaults. Otherwise we're going to have a problem.
$area = $block->getArea();
$found = false;
if (is_object($area)) {
$page = $area->getPage();
if (is_object($page)) {
$type = $page->getType();
$template = $page->getTemplate();
if ($type && $template) {
// Retrieve the page type by handle.
$em = \ORM::entityManager('migration_tool');
$r1 = $em->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\PageType\\PageType');
$pageType = $r1->findOneByHandle($type);
if (is_object($pageType)) {
$defaults = $pageType->getDefaultPageCollection();
foreach ($defaults->getPages() as $default) {
if ($default->getTemplate() == $template) {
// whew. We've located the proper place.
foreach ($default->getAreas() as $area) {
foreach ($area->getBlocks() as $defaultBlock) {
if ($defaultBlock->getDefaultsOutputIdentifier() == $block->getDefaultsOutputIdentifier()) {
$found = true;
}
}
}
}
}
}
}
}
}
if (!$found) {
$action->getTarget()->addMessage(new Message(t('Page Type Defaults Output Reference <strong>%s</strong> not found within corresponding defaults.', $block->getDefaultsOutputIdentifier())));
}
}
}
}
示例10: getByHandle
/**
* @param $ftTypeHandle
*
* @return \Concrete\Core\Entity\File\Image\Thumbnail\Type\Type
*/
public static function getByHandle($ftTypeHandle)
{
// ugh doctrine doesn't cache when searching by ftTypeHandle
$cache = \Core::make('cache/request');
$item = $cache->getItem('file/image/thumbnail/' . $ftTypeHandle);
if (!$item->isMiss()) {
return $item->get();
}
$em = \ORM::entityManager();
$r = $em->getRepository('\\Concrete\\Core\\Entity\\File\\Image\\Thumbnail\\Type\\Type')->findOneBy(array('ftTypeHandle' => $ftTypeHandle));
$cache->save($item->set($r));
return $r;
}
示例11: topicTreeExists
public function topicTreeExists($name, $batch)
{
$tree = Topic::getByName($name);
if (is_object($tree)) {
return true;
}
$r = \ORM::entityManager()->getRepository('\\PortlandLabs\\Concrete5\\MigrationTool\\Entity\\Import\\Tree');
$tree = $r->findOneByName($name);
if (is_object($tree)) {
return true;
}
return false;
}
示例12: createData
protected function createData()
{
$page1 = self::createPage('Page 1');
$page2 = self::createPage('Page 2');
$page3 = self::createPage('Page 3');
$page4 = self::createPage('Page 4');
$subpageA = self::createPage('Subpage A', $page2);
self::createPage('Subpage B', $page2);
self::createPage('Subpage C', $page2);
$feed = new \Concrete\Core\Page\Feed();
$feed->setHandle('blog');
$feed->setParentID(1);
\ORM::entityManager('core')->persist($feed);
\ORM::entityManager('core')->flush();
}
开发者ID:kreativmind,项目名称:concrete5-5.7.0,代码行数:15,代码来源:ContentImporterValueInspectorReplacePageTest.php
示例13: setupDoctrineCommands
public function setupDoctrineCommands()
{
if (!Core::make('app')->isInstalled()) {
return;
}
$helperSet = ConsoleRunner::createHelperSet(\ORM::entityManager('core'));
$this->setHelperSet($helperSet);
$migrationsConfiguration = new MigrationsConfiguration();
/** @var \Doctrine\DBAL\Migrations\Tools\Console\Command\AbstractCommand[] $commands */
$commands = array(new \Doctrine\DBAL\Migrations\Tools\Console\Command\DiffCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\GenerateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\MigrateCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\StatusCommand(), new \Doctrine\DBAL\Migrations\Tools\Console\Command\VersionCommand());
foreach ($commands as $migrationsCommand) {
$migrationsCommand->setMigrationConfiguration($migrationsConfiguration);
$this->add($migrationsCommand);
}
ConsoleRunner::addCommands($this);
}
示例14: add
public static function add($pTemplateHandle, $pTemplateName, $pTemplateIcon = FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, $pkg = null, $pTemplateIsInternal = false)
{
$pkgID = !is_object($pkg) ? 0 : $pkg->getPackageID();
$template = new \Concrete\Core\Entity\Page\Template();
$template->pTemplateHandle = $pTemplateHandle;
$template->pTemplateName = $pTemplateName;
$template->pTemplateIcon = $pTemplateIcon;
$template->pkgID = $pkgID;
$template->pTemplateIsInternal = (bool) $pTemplateIsInternal;
$em = \ORM::entityManager();
$em->persist($template);
$em->flush();
// now that we have added a template, we need to find any page types that can use this template (any page types that allow ALL page templates or all + a template not of this kind)
// and we need to update them to have a reference to this template defaults
$ptlist = PageType::getList();
foreach ($ptlist as $pt) {
$pt->rescanPageTypeComposerOutputControlObjects();
}
return $template;
}
示例15: save_attribute_type_associations
public function save_attribute_type_associations()
{
if (!$this->token->validate('save_attribute_type_associations')) {
$this->error->add(t('Invalid CSRF token. Please refresh and try again.'));
return;
}
$manager = \ORM::entityManager();
$list = Category::getList();
foreach ($list as $cat) {
$cat->clearAttributeKeyCategoryTypes();
if (is_array($this->post($cat->getAttributeKeyCategoryHandle()))) {
foreach ($this->post($cat->getAttributeKeyCategoryHandle()) as $id) {
$type = Type::getByID($id);
$cat->getAttributeTypes()->add($type);
}
}
$this->entityManager->persist($cat);
}
$this->entityManager->flush();
$this->redirect('dashboard/system/attributes/types', 'saved', 'associations_updated');
}