Skip to content
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

EZEE-3085: Added specification ContentTypeSpecification #47

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions eZ/Publish/Core/Specification/Content/ContentTypeSpecification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\Core\Specification\Content;

use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\SPI\Specification\ContentSpecification;

class ContentTypeSpecification implements ContentSpecification
{
/**
* @var string
*/
private $expectedType;

public function __construct(string $expectedType)
{
$this->expectedType = $expectedType;
}

public function isSatisfiedBy(Content $content): bool
{
return $content->getContentType()->identifier === $this->expectedType;
}
}
16 changes: 16 additions & 0 deletions eZ/Publish/SPI/Specification/ContentSpecification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace eZ\Publish\SPI\Specification;

use eZ\Publish\API\Repository\Values\Content\Content;

interface ContentSpecification
{
public function isSatisfiedBy(Content $content): bool;
}