コード例 #1
0
 /**
  * @param int|Post $postId
  *
  * @return string
  *
  * @throws \UnexpectedValueException
  */
 public function getPermalink($postId)
 {
     $post = $postId instanceof Post ? $postId : $this->postManager->find($postId);
     if (!$post) {
         throw new \UnexpectedValueException(sprintf('No post with ID "%d"', $postId));
     }
     $permalinkStructure = $this->optionExtension->getOption('permalink_structure', '')->getValue();
     return $this->replacePostArguments($permalinkStructure, $post);
 }
コード例 #2
0
 /**
  * @param array $context
  * @param Post  $post
  *
  * @return bool
  */
 public function isPostPasswordRequired(array $context, Post $post)
 {
     if (null === $this->cookieHash) {
         $this->cookieHash = '';
         if ($siteUrlOption = $this->optionExtension->getOption('siteurl')) {
             $this->cookieHash = md5($siteUrlOption->getValue());
         }
     }
     return $this->postManager->isPasswordRequired($post, $context['app']->getRequest(), $this->cookieHash);
 }
コード例 #3
0
 /**
  * Check the usage of default return value for a non existing option
  */
 public function testGetOptionUndefined()
 {
     $this->optionManager->expects($this->once())->method('findOneByOptionName')->with($this->equalTo('test'))->will($this->returnValue(null));
     $result = $this->extension->getOption('test', 'poney');
     $this->assertEquals('poney', $result);
 }