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

add InternalExternalLink form type #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bdejacobet
Copy link
Collaborator

@bdejacobet bdejacobet commented Mar 21, 2018

I am targeting this branch, because it is a new feature

Changelog

### Added
- InternalExternalLink form type.

### Changed
- Must add sonata page bundle to your project

To do

  • Add sonata-project/page-bundle to dependencies
  • Add InternalExternalLink form type with all needed elements (js, css, twig, ...)
  • Add validator for InternalExternalLink form type
  • Update the documentation
  • Add tests
  • Add Changelog

Subject

Add InternalExternalLink form type

internal-external-link-choices

internal-external-link-external

internal-external-link-internal-params

internal-external-link-internal-closed

composer.lock Outdated
@@ -0,0 +1,6601 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file should not be commited ;)

## How it works

InternalExternalLink form type groups many fields to record each type of values.
Javascript is use to display form and manage interaction between each field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used

* file that was distributed with this source code.
*
*/
namespace Sonata\SonataHelpersBundle\DependencyInjection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add blank line above plz ;)

*
*/
namespace Sonata\SonataHelpersBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add blank line above plz ;)

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add blank line above plz ;)

->select('page')
->from(Page::class, 'page')
->andWhere('page.requestMethod LIKE :request_method', 'page.routeName NOT LIKE :fos_user')
->andWhere('page.routeName NOT LIKE :sonata_cache', 'page.url IS NOT NULL')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice exclusions ;)
maybe we should add : ->andWhere('page.routeName NOT LIKE :internal_page')
and 'internal_page' => '_page_internal%', in parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. It should use the same filters as the CMS router.
It could be even more handy to get routes directly from the router

@mazsudo
Copy link
Contributor

mazsudo commented Mar 21, 2018

thx @bdejacobet .

Could we imagine in the future to link it with ArticleBundle to also be able to choose a link to an article? ;)

->select('page')
->from(Page::class, 'page')
->andWhere('page.requestMethod LIKE :request_method', 'page.routeName NOT LIKE :fos_user')
->andWhere('page.routeName NOT LIKE :sonata_cache', 'page.url IS NOT NULL')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree. It should use the same filters as the CMS router.
It could be even more handy to get routes directly from the router

])
;

if (null !== $site) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$site can't be null since the function definition doesn't allow it

*
* @author Benoit de Jacobet <[email protected]>
*/
class PageDataTransformer implements DataTransformerInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class has the same behaviour as a normalizer.
It should be integrated using the serializer component of Symfony.
This way we could use context to handle different behaviours
instead of an internal $keysToTransform property

case 'link':
if (!$values['link']) {
$this->context->buildViolation($constraint->message)
->setParameter('{{ error }}', 'Il faut saisir une url externe')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FR text

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants