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

fix getMetadataFor detection #4083

Merged
merged 1 commit into from
Aug 20, 2016
Merged

fix getMetadataFor detection #4083

merged 1 commit into from
Aug 20, 2016

Conversation

rande
Copy link
Member

@rande rande commented Aug 19, 2016

I am targetting this branch, because it is the stable one

Changelog

### Fixed
- Fix how metadata information are retrieved when admin information are dumped

Subject

Fix how metadata information are retrieved when admin information are dumped

}
}

// TODO: remove method check in next major release
Copy link
Contributor

Choose a reason for hiding this comment

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

Please replace TODO with NEXT_MAJOR (we will grep for that before releasing)

@OskarStark
Copy link
Member

@greg0ire when i remember correctly, we have an issue or an open PR which tried to fix this, but which did not work as expected... 💭

@greg0ire
Copy link
Contributor

Yes, this looks oddly familiar…

}
}

// NEXT_MAJOR: remove method check in next major release
Copy link
Member

Choose a reason for hiding this comment

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

if we do this we should trigger a deprecation here

Copy link
Member Author

Choose a reason for hiding this comment

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

No; it is not part of the user land; it is just a command to dump information.

@greg0ire
Copy link
Contributor

greg0ire commented Aug 19, 2016

Here is the history, brought to you by git log -S getMetadataFor -p Command/ExplainAdminCommand.php :

commit 3e7ad359411a5f4ae119d9dc3ef26b3e44716fd1
Author: Thomas Rabaix <thomas.rabaix@gmail.com>
Date:   Mon Nov 23 19:00:57 2015 +0100

    Add support for SF3.0 (WIP)

diff --git a/Command/ExplainAdminCommand.php b/Command/ExplainAdminCommand.php
index 11cfca1..e35235e 100644
--- a/Command/ExplainAdminCommand.php
+++ b/Command/ExplainAdminCommand.php
@@ -89,16 +89,14 @@ public function execute(InputInterface $input, OutputInterface $output)
             $output->writeln(sprintf('  - % -25s  % -15s % -15s', $name, $fieldDescription->getType(), $fieldDescription->getTemplate()));
         }

-        $validator = $this->getContainer()->get('validator');
-        // TODO: Remove conditional method when bumping requirements to SF 2.5+
-        if (method_exists($validator, 'getMetadataFor')) {
-            $metadata = $validator->getMetadataFor($admin->getClass());
+        if ($this->getContainer()->has('validator.validator_factory')) {
+            $metadata = $this->getContainer()->get('validator.validator_factory')->getMetadataFor($admin->getClass());
         } else {
-            $metadata = $validator->getMetadataFactory()->getMetadataFor($admin->getClass());
+            $metadata = $this->getContainer()->get('validator')->getMetadataFor($admin->getClass());
         }

         $output->writeln('');
-        $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/2.0/book/validation.html');
+        $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/3.0/book/validation.html');
         $output->writeln('<info>Properties constraints</info>');

         if (count($metadata->properties) == 0) {

commit baf9d425f67486bc1ca6612fa15adf703a8d1e64
Author: Sullivan SENECHAL <soullivaneuh@gmail.com>
Date:   Fri May 1 12:21:44 2015 +0200

    Fix deprecated getMetadataFactory method usage

diff --git a/Command/ExplainAdminCommand.php b/Command/ExplainAdminCommand.php
index 08800f8..19bd482 100644
--- a/Command/ExplainAdminCommand.php
+++ b/Command/ExplainAdminCommand.php
@@ -90,8 +90,13 @@ public function execute(InputInterface $input, OutputInterface $output)
             $output->writeln(sprintf('  - % -25s  % -15s % -15s', $name, $fieldDescription->getType(), $fieldDescription->getTemplate()));
         }

-        $validatorFactory = $this->getContainer()->get('validator')->getMetadataFactory();
-        $metadata = $validatorFactory->getMetadataFor($admin->getClass());
+        $validator = $this->getContainer()->get('validator');
+        // TODO: Remove conditional method when bumping requirements to SF 2.5+
+        if (method_exists($validator, 'getMetadataFor')) {
+            $metadata = $validator->getMetadataFor($admin->getClass());
+        } else {
+            $metadata = $validator->getMetadataFactory()->getMetadataFor($admin->getClass());
+        }

         $output->writeln('');
         $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/2.0/book/validation.html');

commit 1394100cd8d19aacbde1c70a2e2e529523920f57
Author: Thomas Rabaix <thomas.rabaix@sonata-project.org>
Date:   Fri Jun 7 22:52:49 2013 +0200

    Fix deprecated call

diff --git a/Command/ExplainAdminCommand.php b/Command/ExplainAdminCommand.php
index 6d310b4..c2bbac4 100644
--- a/Command/ExplainAdminCommand.php
+++ b/Command/ExplainAdminCommand.php
@@ -87,7 +87,7 @@ public function execute(InputInterface $input, OutputInterface $output)
         }

         $validatorFactory = $this->getContainer()->get('validator.mapping.class_metadata_factory');
-        $metadata = $validatorFactory->getClassMetadata($admin->getClass());
+        $metadata = $validatorFactory->getMetadataFor($admin->getClass());

         $output->writeln('');
         $output->writeln('<comment>Validation Framework</comment> - http://symfony.com/doc/2.0/book/validation.html');

@greg0ire
Copy link
Contributor

Related : #4045

@rande
Copy link
Member Author

rande commented Aug 19, 2016

All green can we merge ?

@greg0ire
Copy link
Contributor

LGTM

@rande
Copy link
Member Author

rande commented Aug 19, 2016

@OskarStark @soullivaneuh can we merge this PR ?

@greg0ire
Copy link
Contributor

@sonata-project/contributors , final review and merge?

@core23
Copy link
Member

core23 commented Aug 20, 2016

LGTM

@greg0ire greg0ire merged commit 7b205fe into sonata-project:3.x Aug 20, 2016
@greg0ire
Copy link
Contributor

Thanks @rande

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

Successfully merging this pull request may close these issues.

5 participants