/** * {@inheritDoc} * * The default implementation uses get_class on objects */ public function objectToName($object, RdfMapperInterface $mapper) { if (! is_object($object)) { throw new \RuntimeException("$object is not an object"); } return $mapper->canonicalName(get_class($object)); }
protected function getModelBySubject(Request $request, $subject) { $model = $this->rdfMapper->getBySubject($subject); if (empty($model)) { throw new NotFoundHttpException($subject . ' not found'); } return $model; }
protected function getModelBySubject(Request $request, $subject) { $model = $this->rdfMapper->getBySubject($subject); if (empty($model)) { throw new NotFoundHttpException($subject . ' not found'); } if ($this->forceRequestLocale && $model instanceof TranslatableInterface) { $model->setLocale($request->getLocale()); } return $model; }
public function test_loadFromParent_no_children() { $collection = new Collection('test', $this->mockTypeFactory, array('is_child' => true)); $collection->addTypeName('test'); $parent = array('id' => 'test_id'); $this->parentController->test = $collection; $entity = $this->parentController->createWithObject($parent); $children = $entity->test->getChildren(); $this->assertEquals(1, sizeof($children)); $this->assertInstanceOf('Midgard\\CreatePHP\\Entity\\Controller', $children[0]); $this->assertEquals('', $this->mockMapper->createSubject($children[0]->getObject())); $this->assertEquals('display:none', $children[0]->getAttribute('style')); }
public function process_workflow() { if (empty($_GET["subject"])) { throw new midcom_error("no subject passed"); } return new \midcom_response_json($this->_manager->getWorkflows($_GET["subject"])); }
private function prepareBasicTest() { $model = new Model(); $this->twig->addGlobal('mymodel', $model); $container = new Container($model); $this->twig->addGlobal('mycontainer', $container); $this->mapper->expects($this->any())->method('getPropertyValue')->will($this->returnCallback(array($this, 'getPropertyValueCallback'))); $this->mapper->expects($this->any())->method('isEditable')->will($this->returnValue(true)); $this->mapper->expects($this->any())->method('createSubject')->will($this->returnValue('/the/subject')); $this->mapper->expects($this->any())->method('objectToName')->with($model)->will($this->returnValue(get_class($model))); }
/** * Get all workflows available for this subject * * @param string $subject the RDFa identifier of the subject to get workflows for * * @return array of WorkflowInterface */ public function getWorkflows($subject) { $response = array(); $object = $this->_mapper->getBySubject(trim($subject, '<>')); foreach ($this->_workflows as $identifier => $workflow) { /** @var $workflow WorkflowInterface */ $toolbar_config = $workflow->getToolbarConfig($object); if (null !== $toolbar_config) { $response[] = $toolbar_config; } } return $response; }
/** * {@inheritDoc} * * @deprecated Deprecated in 1.1 call on the mapper object instead. */ public function objectToName($object, RdfMapperInterface $mapper) { return $mapper->objectToName($object); }
public function getTypeByObject($object) { return $this->getTypeByName($this->mapper->objectToName($object)); }