Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[PropertyAccess] Allow custom methods on property accesses #18016

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

Closed
wants to merge 18 commits into from
Closed
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
Prev Previous commit
Next Next commit
Addressed @xabbuh and @fabpot comments
  • Loading branch information
lrlopez committed Jul 3, 2016
commit 1e29523a430e54e86fcd49c67d2be02eae98da9a
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\PropertyAccess\Mapping\Loader\AnnotationLoader;
use Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
Expand Down Expand Up @@ -915,13 +917,6 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
}
}

/**
* Loads the PropertyAccess configuration.
*
* @param array $config A serializer configuration array
* @param ContainerBuilder $container A ContainerBuilder instance
* @param XmlFileLoader $loader An XmlFileLoader instance
*/
private function registerPropertyAccessConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
$loader->load('property_access.xml');
Expand All @@ -937,7 +932,7 @@ private function registerPropertyAccessConfiguration(array $config, ContainerBui
$serializerLoaders = array();
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
$annotationLoader = new Definition(
\Symfony\Component\PropertyAccess\Mapping\Loader\AnnotationLoader::class,
AnnotationLoader::class,
array(new Reference('annotation_reader'))
);
$annotationLoader->setPublic(false);
Expand All @@ -951,15 +946,15 @@ private function registerPropertyAccessConfiguration(array $config, ContainerBui
$dirname = dirname($reflection->getFileName());

if (is_file($file = $dirname.'/Resources/config/property_access.xml')) {
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\XmlFileLoader::class, array(realpath($file)));
$definition = new Definition(XmlFileLoader::class, array(realpath($file)));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
$container->addResource(new FileResource($file));
}

if (is_file($file = $dirname.'/Resources/config/property_access.yml')) {
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader::class, array(realpath($file)));
$definition = new Definition(YamlFileLoader::class, array(realpath($file)));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
Expand All @@ -968,13 +963,13 @@ private function registerPropertyAccessConfiguration(array $config, ContainerBui

if (is_dir($dir = $dirname.'/Resources/config/property_access')) {
foreach (Finder::create()->files()->in($dir)->name('*.xml') as $file) {
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\XmlFileLoader::class, array($file->getRealpath()));
$definition = new Definition(XmlFileLoader::class, array($file->getRealpath()));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
}
foreach (Finder::create()->files()->in($dir)->name('*.yml') as $file) {
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader::class, array($file->getRealpath()));
$definition = new Definition(YamlFileLoader::class, array($file->getRealpath()));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ framework:
property_access:
magic_call: true
throw_exception_on_invalid_index: true
enable_annotations: true
enable_annotations: false
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/PropertyAccess/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CHANGELOG
=========

3.1.0
3.2.0
------
* added custom method calling for properties.
Copy link
Member

Choose a reason for hiding this comment

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

This is unclear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll add a more thoughtful explanation


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ class LazyLoadingMetadataFactory implements MetadataFactoryInterface
*
* @var LoaderInterface|null
*/
protected $loader;
private $loader;

/**
* The cache for caching class metadata.
*
* @var CacheItemPoolInterface|null
*/
protected $cache;
private $cache;

/**
* The loaded metadata, indexed by class name.
*
* @var ClassMetadata[]
*/
protected $loadedClasses = array();
private $loadedClasses = array();

/**
* Creates a new metadata factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
/**
* Returns {@link \Symfony\Component\PropertyAccess\Mapping\MetadataInterface} instances for values.
*
* @since 3.1
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
interface MetadataFactoryInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,8 @@
*/
class AnnotationLoader implements LoaderInterface
{
/**
* @var Reader
*/
private $reader;

/**
* @param Reader $reader
*/
public function __construct(Reader $reader)
{
$this->reader = $reader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
*/
class LoaderChain implements LoaderInterface
{
/**
* @var LoaderInterface[]
*/
private $loaders;

/**
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.