- 
                Notifications
    You must be signed in to change notification settings 
- Fork 31
[WIP] Create routes from the front end #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            adou600
  wants to merge
  14
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
create-routes
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from 10 commits
      Commits
    
    
            Show all changes
          
          
            14 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      97ddd4a
              
                create_routes parameter in the config
              
              
                adou600 bf1da4a
              
                WIP 1st functional version of create routes JS handler
              
              
                adou600 7cb10a0
              
                automatic js config for locales, routes and content prefix
              
              
                adou600 c3bfd15
              
                move CmfRoute to the CreateBundle
              
              
                adou600 96c7324
              
                list of rdf types for which to create routes
              
              
                adou600 3dfb241
              
                fix typos
              
              
                adou600 59aa2c5
              
                handle the case where new content and updated content is saved at the…
              
              
                adou600 3ca8690
              
                WIP: use configurable mapper instead of CmfRoute document to set loca…
              
              
                adou600 544d7e0
              
                cleaning and comments after createphp RdfTypeFactory refactoring
              
              
                adou600 b154d18
              
                improve error handling for frontend route creation
              
              
                adou600 34115e0
              
                various fixes after lsmith77 review
              
              
                adou600 d436362
              
                tmp fix for create.js bug
              
              
                adou600 2468b8a
              
                typos on error messages
              
              
                adou600 4fdffc6
              
                Merge master
              
              
                adou600 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or 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
    
  
  
    
              
  
    
      This file contains hidden or 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -115,16 +115,22 @@ public function postDocumentAction(Request $request) | |
| $this->performSecurityChecks(); | ||
|  | ||
| $rdfType = trim($request->request->get('@type'), '<>'); | ||
|  | ||
| $type = $this->typeFactory->getTypeByRdf($rdfType); | ||
|  | ||
| $result = $this->restHandler->run($request->request->all(), $type, null, RestService::HTTP_POST); | ||
| $result = null; | ||
| try { | ||
| $result = $this->restHandler->run($request->request->all(), $type, null, RestService::HTTP_POST); | ||
| } catch (\Exception $e) { | ||
| return Response::create("The document of type \"$rdfType\" could not be created: " . $e->getMessage(), 500); | ||
| } | ||
|  | ||
| if (!is_null($result)) { | ||
| $view = View::create($result)->setFormat('json'); | ||
| return $this->viewHandler->handle($view, $request); | ||
| } | ||
|  | ||
| return Response::create('The document could not be created', 500); | ||
| return Response::create("The document \"$rdfType\" could not be created", 500); | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not just  | ||
| } | ||
|  | ||
| /** | ||
|  | ||
  
    
      This file contains hidden or 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
    
  
  
    
              
  
    
      This file contains hidden or 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
    
  
  
    
              
  
    
      This file contains hidden or 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|  | ||
| namespace Symfony\Cmf\Bundle\CreateBundle\Mapper; | ||
|  | ||
| use Midgard\CreatePHP\Mapper\DoctrinePhpcrOdmMapper; | ||
|  | ||
| use Midgard\CreatePHP\Entity\PropertyInterface; | ||
|  | ||
| use Symfony\Cmf\Bundle\RoutingExtraBundle\Document\Route; | ||
|  | ||
| /** | ||
| * Mapper to handle route documents stored in PHPCR-ODM. | ||
| */ | ||
| class RouteDoctrinePhpcrOdmMapper extends DoctrinePhpcrOdmMapper | ||
| { | ||
| public function setPropertyValue($object, PropertyInterface $property, $value) | ||
| { | ||
| if ($object instanceof Route && $property->getIdentifier() === 'locale') { | ||
| $object->setDefault('_locale', $value); | ||
| $object->setRequirement('_locale', $value); | ||
| return $object; | ||
| } | ||
| return parent::setPropertyValue($object, $property, $value); | ||
| } | ||
|  | ||
| public function getPropertyValue($object, PropertyInterface $property) | ||
| { | ||
| if ($object instanceof Route && $property->getIdentifier() === 'locale') { | ||
| return $object->getDefault('_locale'); | ||
| } | ||
| return parent::getPropertyValue($object, $property); | ||
| } | ||
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <?php | ||
|  | ||
| namespace Symfony\Cmf\Bundle\CreateBundle\Metadata; | ||
|  | ||
| use Midgard\CreatePHP\RdfMapperInterface; | ||
| use Midgard\CreatePHP\Type\TypeInterface; | ||
|  | ||
| use Midgard\CreatePHP\Metadata\RdfTypeFactory; | ||
|  | ||
| use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
| use Symfony\Component\DependencyInjection\ContainerInterface; | ||
| use Midgard\CreatePHP\Metadata\RdfDriverInterface; | ||
|  | ||
| /** | ||
| * Factory for createphp types based on class names. If available, the mappers | ||
| * for the requested class are loaded from the Symfony service container. | ||
| */ | ||
| class ContainerRdfTypeFactory extends RdfTypeFactory implements ContainerAwareInterface | ||
| { | ||
| /** | ||
| * @var array service names of the mappers | ||
| */ | ||
| private $mapperServices; | ||
|  | ||
| /** | ||
| * @var ContainerInterface | ||
| */ | ||
| protected $container; | ||
|  | ||
| /** | ||
| * @param RdfMapperInterface $defaultMapper the default mapper to use if there is no specific one | ||
| * @param RdfDriverInterface $driver the driver to load types from | ||
| * @param array $mappers rdf mappers per service name | ||
| */ | ||
| public function __construct(RdfMapperInterface $defaultMapper, RdfDriverInterface $driver, $mapperServices = array()) | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a  | ||
| { | ||
| $this->mapperServices = $mapperServices; | ||
| parent::__construct($defaultMapper, $driver); | ||
| } | ||
|  | ||
| /** | ||
| * Get the mapper for type $name in the $symfony container, or the defaultMapper if there is no specific one | ||
| * | ||
| * @param string $name the type name for which to get the mapper | ||
| * | ||
| * @return RdfMapperInterface | ||
| */ | ||
| protected function getMapper($name) | ||
| { | ||
| if (isset($this->mapperServices[$name])) { | ||
| return $this->container->get($this->mapperServices[$name]); | ||
| } | ||
|  | ||
| return parent::getMapper($name); | ||
| } | ||
|  | ||
| /** | ||
| * @see ContainerAwareInterface::setContainer() | ||
| */ | ||
| public function setContainer(ContainerInterface $container = null) | ||
| { | ||
| $this->container = $container; | ||
| } | ||
| } | ||
  
    
      This file contains hidden or 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
    
  
  
    
              
  
    
      This file contains hidden or 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
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer you inject the parameters explicitly .. if you want you can inject them all as an array