当前位置: 首页>>代码示例>>PHP>>正文


PHP record_adapter::hasChild方法代码示例

本文整理汇总了PHP中record_adapter::hasChild方法的典型用法代码示例。如果您正苦于以下问题:PHP record_adapter::hasChild方法的具体用法?PHP record_adapter::hasChild怎么用?PHP record_adapter::hasChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在record_adapter的用法示例。


在下文中一共展示了record_adapter::hasChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addElementsAction

 public function addElementsAction(Request $request, $sbas_id, $record_id)
 {
     $Story = new \record_adapter($this->app, $sbas_id, $record_id);
     if (!$this->getAclForUser()->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
         throw new AccessDeniedHttpException('You can not add document to this Story');
     }
     $n = 0;
     $records = RecordsRequest::fromRequest($this->app, $request, true);
     foreach ($records as $record) {
         if ($Story->hasChild($record)) {
             continue;
         }
         $Story->appendChild($record);
         $n++;
     }
     $this->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($Story));
     $data = ['success' => true, 'message' => $this->app->trans('%quantity% records added', ['%quantity%' => $n])];
     if ($request->getRequestFormat() == 'json') {
         return $this->app->json($data);
     }
     return $this->app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:22,代码来源:StoryController.php

示例2: connect

 public function connect(Application $app)
 {
     $app['controller.prod.story'] = $this;
     $controllers = $app['controllers_factory'];
     $app['firewall']->addMandatoryAuthentication($controllers);
     $controllers->get('/create/', function (Application $app) {
         return $app['twig']->render('prod/Story/Create.html.twig', []);
     })->bind('prod_stories_create');
     $controllers->post('/', function (Application $app, Request $request) {
         /* @var $request \Symfony\Component\HttpFoundation\Request */
         $collection = \collection::get_from_base_id($app, $request->request->get('base_id'));
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($collection->get_base_id(), 'canaddrecord')) {
             throw new AccessDeniedHttpException('You can not create a story on this collection');
         }
         $Story = \record_adapter::createStory($app, $collection);
         $records = RecordsRequest::fromRequest($app, $request, true);
         foreach ($records as $record) {
             if ($Story->hasChild($record)) {
                 continue;
             }
             $Story->appendChild($record);
         }
         $metadatas = [];
         foreach ($collection->get_databox()->get_meta_structure() as $meta) {
             if ($meta->get_thumbtitle()) {
                 $value = $request->request->get('name');
             } else {
                 continue;
             }
             $metadatas[] = ['meta_struct_id' => $meta->get_id(), 'meta_id' => null, 'value' => $value];
             break;
         }
         $Story->set_metadatas($metadatas)->rebuild_subdefs();
         $StoryWZ = new StoryWZ();
         $StoryWZ->setUser($app['authentication']->getUser());
         $StoryWZ->setRecord($Story);
         $app['EM']->persist($StoryWZ);
         $app['EM']->flush();
         if ($request->getRequestFormat() == 'json') {
             $data = ['success' => true, 'message' => $app->trans('Story created'), 'WorkZone' => $StoryWZ->getId(), 'story' => ['sbas_id' => $Story->get_sbas_id(), 'record_id' => $Story->get_record_id()]];
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $StoryWZ->getSbasId(), 'record_id' => $StoryWZ->getRecordId()]);
         }
     })->bind('prod_stories_do_create');
     $controllers->get('/{sbas_id}/{record_id}/', function (Application $app, $sbas_id, $record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         $html = $app['twig']->render('prod/WorkZone/Story.html.twig', ['Story' => $Story]);
         return new Response($html);
     })->bind('prod_stories_story')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/addElements/', function (Application $app, Request $request, $sbas_id, $record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
             throw new AccessDeniedHttpException('You can not add document to this Story');
         }
         $n = 0;
         $records = RecordsRequest::fromRequest($app, $request, true);
         foreach ($records as $record) {
             if ($Story->hasChild($record)) {
                 continue;
             }
             $Story->appendChild($record);
             $n++;
         }
         $data = ['success' => true, 'message' => $app->trans('%quantity% records added', ['%quantity%' => $n])];
         if ($request->getRequestFormat() == 'json') {
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
         }
     })->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/delete/{child_sbas_id}/{child_record_id}/', function (Application $app, Request $request, $sbas_id, $record_id, $child_sbas_id, $child_record_id) {
         $Story = new \record_adapter($app, $sbas_id, $record_id);
         $record = new \record_adapter($app, $child_sbas_id, $child_record_id);
         if (!$app['acl']->get($app['authentication']->getUser())->has_right_on_base($Story->get_base_id(), 'canmodifrecord')) {
             throw new AccessDeniedHttpException('You can not add document to this Story');
         }
         $Story->removeChild($record);
         $data = ['success' => true, 'message' => $app->trans('Record removed from story')];
         if ($request->getRequestFormat() == 'json') {
             return $app->json($data);
         } else {
             return $app->redirectPath('prod_stories_story', ['sbas_id' => $sbas_id, 'record_id' => $record_id]);
         }
     })->bind('prod_stories_story_remove_element')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+')->assert('child_sbas_id', '\\d+')->assert('child_record_id', '\\d+');
     /**
      * Get the Basket reorder form
      */
     $controllers->get('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
         $story = new \record_adapter($app, $sbas_id, $record_id);
         if (!$story->is_grouping()) {
             throw new \Exception('This is not a story');
         }
         return new Response($app['twig']->render('prod/Story/Reorder.html.twig', ['story' => $story]));
     })->bind('prod_stories_story_reorder')->assert('sbas_id', '\\d+')->assert('record_id', '\\d+');
     $controllers->post('/{sbas_id}/{record_id}/reorder/', function (Application $app, $sbas_id, $record_id) {
         $ret = ['success' => false, 'message' => $app->trans('An error occured')];
         try {
             $story = new \record_adapter($app, $sbas_id, $record_id);
             if (!$story->is_grouping()) {
//.........这里部分代码省略.........
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:101,代码来源:Story.php

示例3: setStoryCover

 protected function setStoryCover(\record_adapter $story, $record_id, $can_fail = false)
 {
     try {
         $record = new \record_adapter($this->app, $story->getDataboxId(), $record_id);
     } catch (\Exception_Record_AdapterNotFound $e) {
         $record = null;
         $this->app->abort(404, sprintf('Record identified by databox_id %s and record_id %s could not be found', $story->getDataboxId(), $record_id));
     }
     if (!$story->hasChild($record)) {
         $this->app->abort(404, sprintf('Record identified by databox_id %s and record_id %s is not in the story', $story->getDataboxId(), $record_id));
     }
     if ($record->getType() !== 'image' && $record->getType() !== 'video') {
         // this can fail so we can loop on many records during story creation...
         if ($can_fail) {
             return false;
         }
         $this->app->abort(403, sprintf('Record identified by databox_id %s and record_id %s is not an image nor a video', $story->getDataboxId(), $record_id));
     }
     foreach ($record->get_subdefs() as $name => $value) {
         if (!in_array($name, array('thumbnail', 'preview'))) {
             continue;
         }
         $media = $this->app->getMediaFromUri($value->get_pathfile());
         $story->substitute_subdef($name, $media, $this->app);
         $this->getDataboxLogger($story->getDatabox())->log($story, \Session_Logger::EVENT_SUBSTITUTE, $name == 'document' ? 'HD' : $name, '');
     }
     $this->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($story));
     return $record->get_serialize_key();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:29,代码来源:V1Controller.php


注:本文中的record_adapter::hasChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。