Created
June 16, 2014 14:35
-
-
Save pspanja/a0b742a5e78aa75739f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PageController extends Controller | |
{ | |
... | |
/** | |
* | |
* | |
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException | |
* | |
* @param mixed $id | |
* @param array $params | |
* @param array $cacheSettings | |
* | |
* @return Response | |
*/ | |
public function viewBlockById( $id, array $params = array(), array $cacheSettings = array() ) | |
{ | |
$locationId = $this->pageService->getLocationIdByBlockId( $id ); | |
$location = $this->getRepository()->getLocationService()->loadLocation( $locationId ); | |
$content = $this->getRepository()->getContentService()->loadContent( $location->contentId ); | |
foreach ( $content->fields as $field ) | |
{ | |
if ( $field instanceof Value ) | |
{ | |
foreach ( $field->page->zones as $zone ) | |
{ | |
foreach ( $zone->blocks as $block ) | |
{ | |
if ( $block->id === $id ) | |
{ | |
return $this->viewBlock( | |
$block, | |
$params, | |
$cacheSettings | |
); | |
} | |
} | |
} | |
} | |
} | |
throw new NotFoundException( "Block", $id ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment