8000 [PropertyAccess] Allow custom methods on property accesses by lrlopez · Pull Request #18016 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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
Renamed Attribute to Property on most classes and methods
  • Loading branch information
lrlopez committed Jul 3, 2016
commit 00a26eb53bf4087a4d192fe6c0ec5f7b57c08c20
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,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',
\Symfony\Component\PropertyAccess\Mapping\Loader\AnnotationLoader::class,
Copy link
Member

Choose a reason for hiding this comment

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

please add a use statement for this class

array(new Reference('annotation_reader'))
);
$annotationLoader->setPublic(false);
Expand All @@ -954,15 +954,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', array(realpath($file)));
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\XmlFileLoader::class, array(realpath($file)));
Copy link
Member

Choose a reason for hiding this comment

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

You should add a use statement to avoid having the FQCN here (same below).

$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', array(realpath($file)));
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader::class, array(realpath($file)));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
Expand All @@ -971,13 +971,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', array($file->getRealpath()));
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\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', array($file->getRealpath()));
$definition = new Definition(\Symfony\Component\PropertyAccess\Mapping\Loader\YamlFileLoader::class, array($file->getRealpath()));
$definition->setPublic(false);

$serializerLoaders[] = $definition;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,33 @@
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class PropertyAccessor extends ConfigurationAnnotation
class PropertyAccessor
{
protected $setter;

protected $getter;

protected $adder;

protected $remover;

public function getSetter()
{
return $this->setter;
}

public function setSetter($setter)
{
$this->setter = $setter;
}

public function getGetter()
{
return $this->getter;
}

public function setGetter($getter)
{
$this->getter = $getter;
}

public function getAdder()
{
return $this->adder;
}

public function setAdder($adder)
{
$this->adder = $adder;
}

public function getRemover()
{
return $this->remover;
}

public function setRemover($remover)
{
$this->remover = $remover;
}
/**
* Custom setter method for the property
*
* @var string $setter
*/
public $setter;

/**
* Custom getter method for the property
*
* @var string $setter
*/
public $getter;

/**
* Custom adder method for the property
*
* @var string $setter
*/
public $adder;

/**
* Custom remover method for the property
*
* @var string $setter
*/
public $remover;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* MappingException.
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class MappingException extends RuntimeException
{
Expand Down

This file was deleted.

50 changes: 30 additions & 20 deletions src/Symfony/Component/PropertyAccess/Mapping/ClassMetadata.php