Пример #1
0
 public function __construct(Request $request, Session $session, Editor $editor)
 {
     $this->session = $session;
     $this->request = $request;
     $this->auth = Auth::getFacadeRoot();
     $this->editor = $editor;
     $this->person = $this->auth->getPerson();
     if ($this->role) {
         $this->authorization($this->role);
     }
 }
Пример #2
0
 public function testGetPersonReturnsPerson()
 {
     $personId = 1;
     $session = $this->getMockSession();
     $session->expects($this->once())->method('get')->with($this->anything())->will($this->returnValue($personId));
     $permissions = $this->getMockPermissionsProvider();
     $repository = $this->getMockPersonRepository(['find']);
     $repository->expects($this->once())->method('find')->with($this->equalTo($personId))->will($this->returnValue('person'));
     $auth = new Auth($session, $repository, $permissions);
     $this->assertEquals('person', $auth->getPerson());
 }
Пример #3
0
 /**
  * Returns whether or not the logged in user can edit the content of a page.
  * 
  * A page can be edited if it was created by a user or they have edit permissions for the page.
  * 
  * @param Page $page
  *
  * @return bool
  */
 public function isEditable(Page $page)
 {
     return $page->wasCreatedBy($this->auth->getPerson()) || $this->auth->loggedIn('edit_page_content', $page);
 }