-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from patrick477/master
[General] Add resources render by section code
- Loading branch information
Showing
22 changed files
with
248 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* another great project. | ||
* You can find more information about us on https://bitbag.shop and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\CmsPlugin\Entity; | ||
|
||
use BitBag\CmsPlugin\Entity\Section; | ||
use BitBag\CmsPlugin\Entity\SectionInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class SectionSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable(): void | ||
{ | ||
$this->shouldHaveType(Section::class); | ||
} | ||
|
||
function it_is_a_resource(): void | ||
{ | ||
$this->shouldHaveType(ResourceInterface::class); | ||
} | ||
|
||
function it_implements_section_interface(): void | ||
{ | ||
$this->shouldHaveType(SectionInterface::class); | ||
} | ||
|
||
function it_allows_access_via_properties(): void | ||
{ | ||
$this->setCode('blog'); | ||
$this->getCode()->shouldReturn('blog'); | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
|
||
/** | ||
* This file was created by the developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* another great project. | ||
* You can find more information about us on https://bitbag.shop and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\BitBag\CmsPlugin\Entity; | ||
|
||
use BitBag\CmsPlugin\Entity\SectionTranslation; | ||
use BitBag\CmsPlugin\Entity\SectionTranslationInterface; | ||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
use Sylius\Component\Resource\Model\TranslationInterface; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
final class SectionTranslationSpec extends ObjectBehavior | ||
{ | ||
function it_is_initializable() | ||
{ | ||
$this->shouldHaveType(SectionTranslation::class); | ||
} | ||
|
||
function it_is_a_resource() | ||
{ | ||
$this->shouldHaveType(ResourceInterface::class); | ||
} | ||
|
||
function it_implements_frequently_asked_question_translation_interface() | ||
{ | ||
$this->shouldHaveType(SectionTranslationInterface::class); | ||
$this->shouldHaveType(TranslationInterface::class); | ||
} | ||
|
||
function it_allows_access_via_properties() | ||
{ | ||
$this->setName('Blog'); | ||
$this->getName()->shouldReturn('Blog'); | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
|
||
/** | ||
* @author Mikołaj Król <[email protected]> | ||
* @author Patryk Drapik <[email protected]> | ||
*/ | ||
interface FrequentlyAskedQuestionRepositoryInterface extends RepositoryInterface | ||
{ | ||
|
@@ -29,7 +30,7 @@ public function createListQueryBuilder(): QueryBuilder; | |
/** | ||
* @param string $localeCode | ||
* | ||
* @return QueryBuilder | ||
* @return array|FrequentlyAskedQuestionInterface[] | ||
*/ | ||
public function findEnabledOrderedByPosition(string $localeCode): array; | ||
|
||
|
@@ -39,4 +40,11 @@ public function findEnabledOrderedByPosition(string $localeCode): array; | |
* @return null|FrequentlyAskedQuestionInterface | ||
*/ | ||
public function findEnabledByCode(string $code): ?FrequentlyAskedQuestionInterface; | ||
|
||
/** | ||
* @param string $sectionCode | ||
* | ||
* @return FrequentlyAskedQuestionInterface[] | ||
*/ | ||
public function findEnabledBySectionCode(string $sectionCode): array; | ||
} |
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 |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
use BitBag\CmsPlugin\Entity\PageInterface; | ||
use Doctrine\ORM\QueryBuilder; | ||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
|
||
/** | ||
* @author Patryk Drapik <[email protected]> | ||
|
@@ -64,4 +63,19 @@ public function findEnabledBySlug(string $slug, string $localeCode): ?PageInterf | |
->getOneOrNullResult() | ||
; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function findEnabledBySectionCode(string $code): array | ||
{ | ||
return $this->createQueryBuilder('o') | ||
->innerJoin('o.sections', 'section') | ||
->andWhere('section.code = :sectionCode') | ||
->andWhere('o.enabled = true') | ||
->setParameter('sectionCode', $code) | ||
->getQuery() | ||
->getResult() | ||
; | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.