Skip to content

Instantly share code, notes, and snippets.

@Chrysweel
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save Chrysweel/b001e83d6e3c7e936f11 to your computer and use it in GitHub Desktop.

Select an option

Save Chrysweel/b001e83d6e3c7e936f11 to your computer and use it in GitHub Desktop.

Revisions

  1. Chrysweel revised this gist Jun 6, 2014. 1 changed file with 15 additions and 33 deletions.
    48 changes: 15 additions & 33 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,33 +1,15 @@
    <?php

    public function postChannelsAction(Request $request)
    {
    $newChannel = null;
    try {
    $channelInitializeEvent = new ChannelInitializeEvent($this->getUser(),$request);
    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_INITIALIZE, $channelInitializeEvent);

    if ($channelInitializeEvent->isAborted()){
    return $this->serviceError($channelInitializeEvent->getCodeMessageError(),403);
    }

    $newChannel = $this->get('api_bundle.form.handler.channel_handler')->post($request->request->all());

    $response = $this->buildResourceView($newChannel, 201, 'channel_show');

    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_COMPLETED, new ChannelEvent($newChannel,$this->getUser(),$request,$response));

    return $response;

    }catch (InvalidFormException $exception) {
    return $this->buildFormErrorsView($exception->getForm());
    }catch(AbortSaveChannelException $ex){
    //this exception is trowed when event channel_created_success is aborted
    return $this->createError($ex->getMessage(),$ex->getCode(),404);
    }catch(\Exception $ex){
    if($newChannel != null){
    $this->get('chatea_api.manager.channel.default')->delete($newChannel);
    }
    return $this->createError($ex->getMessage(),60,404);
    }
    }
    1) Chatea\MyBundle\Tests\Controller\ChannelControllerTest::testSecurityRolesCanCreateChannelAction
    Invalid argument supplied for foreach()

    /var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:371
    /var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php:129
    /var/www/workspace/apiChatea/app/bootstrap.php.cache:2867
    /var/www/workspace/apiChatea/app/bootstrap.php.cache:2820
    /var/www/workspace/apiChatea/app/bootstrap.php.cache:2944
    /var/www/workspace/apiChatea/app/bootstrap.php.cache:2245
    /var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Client.php:81
    /var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Client.php:111
    /var/www/workspace/apiChatea/vendor/symfony/symfony/src/Symfony/Component/BrowserKit/Client.php:330
    /var/www/workspace/apiChatea/src/Chatea/MyBundle/Tests/Controller/ChannelControllerTest.php:99
    /usr/share/php/PHPUnit/TextUI/Command.php:192
    /usr/share/php/PHPUnit/TextUI/Command.php:130
  2. Chrysweel revised this gist Jun 6, 2014. 1 changed file with 8 additions and 7 deletions.
    15 changes: 8 additions & 7 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <?php
    public function postChannelsAction(Request $request)
    {

    public function postChannelsAction(Request $request)
    {
    $newChannel = null;
    try {
    $channelInitializeEvent = new ChannelInitializeEvent($this->getUser(),$request);
    @@ -12,14 +13,14 @@ public function postChannelsAction(Request $request)

    $newChannel = $this->get('api_bundle.form.handler.channel_handler')->post($request->request->all());

    $response = $this->buildResourceView($newChannel, 201, 'channel_show');
    $response = $this->buildResourceView($newChannel, 201, 'channel_show');

    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_COMPLETED, new ChannelEvent($newChannel,$this->getUser(),$request,$response));
    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_COMPLETED, new ChannelEvent($newChannel,$this->getUser(),$request,$response));

    return $response;
    return $response;

    }catch (InvalidFormException $exception) {
    return $this->buildFormErrorsView($exception->getForm());
    return $this->buildFormErrorsView($exception->getForm());
    }catch(AbortSaveChannelException $ex){
    //this exception is trowed when event channel_created_success is aborted
    return $this->createError($ex->getMessage(),$ex->getCode(),404);
    @@ -29,4 +30,4 @@ public function postChannelsAction(Request $request)
    }
    return $this->createError($ex->getMessage(),60,404);
    }
    }
    }
  3. Chrysweel revised this gist Jun 6, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    public function postChannelsAction(Request $request)
    {
    $newChannel = null;
  4. Chrysweel renamed this gist Jun 6, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. Chrysweel created this gist Jun 6, 2014.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    public function postChannelsAction(Request $request)
    {
    $newChannel = null;
    try {
    $channelInitializeEvent = new ChannelInitializeEvent($this->getUser(),$request);
    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_INITIALIZE, $channelInitializeEvent);

    if ($channelInitializeEvent->isAborted()){
    return $this->serviceError($channelInitializeEvent->getCodeMessageError(),403);
    }

    $newChannel = $this->get('api_bundle.form.handler.channel_handler')->post($request->request->all());

    $response = $this->buildResourceView($newChannel, 201, 'channel_show');

    $this->dispatchEvent(ApiChannelEvents::CHANNEL_CREATED_COMPLETED, new ChannelEvent($newChannel,$this->getUser(),$request,$response));

    return $response;

    }catch (InvalidFormException $exception) {
    return $this->buildFormErrorsView($exception->getForm());
    }catch(AbortSaveChannelException $ex){
    //this exception is trowed when event channel_created_success is aborted
    return $this->createError($ex->getMessage(),$ex->getCode(),404);
    }catch(\Exception $ex){
    if($newChannel != null){
    $this->get('chatea_api.manager.channel.default')->delete($newChannel);
    }
    return $this->createError($ex->getMessage(),60,404);
    }
    }