Example #1
0
 /**
  * 문서 삭제
  *
  * @param ItemEntity     $item   board item entity
  * @param ConfigEntity   $config destination board config entity
  * @return int
  */
 public function remove(ItemEntity $item, ConfigEntity $config)
 {
     $item = $this->get($item->id, $item->instanceId);
     // 덧글이 있다면 덧글들을 모두 휴지통으로 옯긴다.
     $count = 0;
     if ($config->get('recursiveDelete') === true) {
         $rows = $this->document->getRepository()->getReplies($item->getDocument());
         foreach ($rows as $row) {
             $item = $this->get($row['id'], $row['instanceId']);
             $count = $this->document->remove($item->getDocument());
             $this->slug->delete($item->getSlug());
             /** @var \Xpressengine\Storage\File $file */
             foreach ($this->storage->getsByTargetId($item->id) as $file) {
                 $this->storage->unBind($item->id, $file, true);
             }
         }
     } else {
         $count = $this->document->remove($item->getDocument());
         $this->slug->delete($item->getSlug());
         /** @var \Xpressengine\Storage\File $file */
         foreach ($this->storage->getsByTargetId($item->id) as $file) {
             $this->storage->unBind($item->id, $file, true);
         }
     }
     return $count;
 }
Example #2
0
 /**
  * Get site representative image
  *
  * @return Image
  */
 public function getSiteImage()
 {
     if (!$this->image && $this->get('uuid')) {
         $files = $this->storage->getsByTargetId($this->get('uuid'));
         if (count($files) > 0) {
             $file = current($files);
             $this->image = $this->media->make($file);
         }
     }
     return $this->image;
 }
 public function testGetsByTargetId()
 {
     list($handler, $repo, $auth, $keygen) = $this->getMocks();
     $mockFile1 = m::mock('Xpressengine\\Storage\\File');
     $mockFile2 = m::mock('Xpressengine\\Storage\\File');
     $repo->shouldReceive('fetchByTargetId')->once()->with('targetidstring')->andReturn([$mockFile1, $mockFile2]);
     $instance = new Storage($handler, $repo, $auth, $keygen);
     $files = $instance->getsByTargetId('targetidstring');
     $this->assertEquals(2, count($files));
 }