-
-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to declare empty item operations
- Loading branch information
Showing
7 changed files
with
163 additions
and
13 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Action; | ||
|
||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
/** | ||
* Not found action. | ||
* | ||
* @author Antoine Bluchet <soyuka@gmail.com> | ||
*/ | ||
final class NotFoundAction | ||
{ | ||
public function __invoke() | ||
{ | ||
throw new NotFoundHttpException(); | ||
} | ||
} |
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
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
52 changes: 52 additions & 0 deletions
52
tests/Fixtures/TestBundle/Document/DisableItemOperation.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Document; | ||
|
||
use ApiPlatform\Core\Action\NotFoundAction; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
|
||
/** | ||
* DisableItemOperation. | ||
* | ||
* @author Antoine Bluchet <soyuka@gmail.com> | ||
* | ||
* @ApiResource(itemOperations={ | ||
* "get"={ | ||
* "read"=false, | ||
* "output"=false, | ||
* "controller"=NotFoundAction::class | ||
* } | ||
* }, collectionOperations={"get"}) | ||
* @ODM\Document | ||
*/ | ||
class DisableItemOperation | ||
{ | ||
/** | ||
* @ODM\Id(strategy="INCREMENT", type="integer") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string The dummy name | ||
* | ||
* @ODM\Field | ||
*/ | ||
public $name; | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Core\Action\NotFoundAction; | ||
use ApiPlatform\Core\Annotation\ApiResource; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
/** | ||
* DisableItemOperation. | ||
* | ||
* @author Antoine Bluchet <soyuka@gmail.com> | ||
* | ||
* @ApiResource(itemOperations={ | ||
* "get"={ | ||
* "read"=false, | ||
* "output"=false, | ||
* "controller"=NotFoundAction::class | ||
* } | ||
* }, collectionOperations={"get"}) | ||
* @ORM\Entity | ||
*/ | ||
class DisableItemOperation | ||
{ | ||
/** | ||
* @var int The id | ||
* | ||
* @ORM\Column(type="integer", nullable=true) | ||
* @ORM\Id | ||
* @ORM\GeneratedValue(strategy="AUTO") | ||
*/ | ||
private $id; | ||
|
||
/** | ||
* @var string The dummy name | ||
* | ||
* @ORM\Column | ||
*/ | ||
public $name; | ||
|
||
public function getId() | ||
{ | ||
return $this->id; | ||
} | ||
} |
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