Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[PropertyAccess] [For reference only] Allow custom property accessors#38515

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes fromall commits
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Annotation;

/**
* Property accessor adder configuration annotation.
*
* @Annotation
* @Target({"METHOD"})
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class AdderAccessor
{
/**
* Associates this method to the adder of this property.
*
* @var string
*/
public $property;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Annotation;

/**
* Property accessor getter configuration annotation.
*
* @Annotation
* @Target({"METHOD"})
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class GetterAccessor
{
/**
* Associates this method to the getter of this property.
*
* @var string
*/
public $property;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Annotation;

/**
* Property accessor configuration annotation.
*
* @Annotation
* @Target({"PROPERTY"})
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class PropertyAccessor
{
/**
* Custom setter method for the property.
*
* @var string
*/
public $setter;

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

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

/**
* Custom remover method for the property.
*
* @var string
*/
public $remover;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Annotation;

/**
* Property accessor remover configuration annotation.
*
* @Annotation
* @Target({"METHOD"})
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class RemoverAccessor
{
/**
* Associates this method to the remover of this property.
*
* @var string
*/
public $property;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Annotation;

/**
* Property accessor setter configuration annotation.
*
* @Annotation
* @Target({"METHOD"})
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class SetterAccessor
{
/**
* Associates this method to the setter of this property.
*
* @var string
*/
public $property;
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Exception;

/**
* MappingException.
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class MappingException extends RuntimeException
{
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Exception;

/**
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class NoSuchMetadataException extends AccessException
{
}
136 changes: 136 additions & 0 deletionssrc/Symfony/Component/PropertyAccess/Mapping/ClassMetadata.php
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Mapping;

/**
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class ClassMetadata
{
/**
* @var string
*
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
* {@link getName()} instead.
*/
public $name;

/**
* @var PropertyMetadata[]
*
* @internal This property is public in order to reduce the size of the
* class' serialized representation. Do not access it. Use
* {@link getPropertyMetadataCollection()} instead.
*/
public $propertyMetadataCollection = array();

/**
* @var \ReflectionClass
*/
private $reflClass;

/**
* Constructs a metadata for the given class.
*
* @param string $class
*/
public function __construct($class)
{
$this->name = $class;
}

/**
* Returns the name of the backing PHP class.
*
* @return string the name of the backing class
*/
public function getName()
{
return $this->name;
}

/**
* Adds an {@link AttributeMetadataInterface}.
*
* @param PropertyMetadata $propertyMetadata
*/
public function addPropertyMetadata(PropertyMetadata $propertyMetadata)
{
$this->propertyMetadataCollection[$propertyMetadata->getName()] = $propertyMetadata;
}

/**
* Gets the list of {@link PropertyMetadata}.
*
* @return PropertyMetadata[]
*/
public function getPropertyMetadataCollection()
{
return $this->propertyMetadataCollection;
}

/**
* Return metadata for a particular property, or null if it doesn't exist.
*
* @param string $property
*
* @return PropertyMetadata|null
*/
public function getMetadataForProperty($property)
{
return isset($this->propertyMetadataCollection[$property]) ? $this->propertyMetadataCollection[$property] : null;
}

/**
* Merges a {@link ClassMetadata} into the current one.
*
* @param self $classMetadata
*/
public function merge(ClassMetadata $classMetadata)
{
foreach ($classMetadata->getPropertyMetadataCollection() as $attributeMetadata) {
if (isset($this->propertyMetadataCollection[$attributeMetadata->getName()])) {
$this->propertyMetadataCollection[$attributeMetadata->getName()]->merge($attributeMetadata);
} else {
$this->addPropertyMetadata($attributeMetadata);
}
}
}

/**
* Returns a {@link \ReflectionClass} instance for this class.
*
* @return \ReflectionClass
*/
public function getReflectionClass()
{
if (!$this->reflClass) {
$this->reflClass = new \ReflectionClass($this->getName());
}

return $this->reflClass;
}

/**
* Returns the names of the properties that should be serialized.
*
* @return string[]
*/
public function __sleep()
{
return array(
'name',
'propertyMetadataCollection',
);
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\PropertyAccess\Mapping\Factory;

/**
* Metadata factory that does not store metadata.
*
* This implementation is useful if you want to validate values against
* constraints only and you don't need to add constraints to classes and
* properties.
*
* @author Luis Ramón López <lrlopez@gmail.com>
*/
class BlackHoleMetadataFactory implements MetadataFactoryInterface
{
/**
* {@inheritdoc}
*/
public function getMetadataFor($value)
{
throw new \LogicException('This class does not support metadata.');
}

/**
* {@inheritdoc}
*/
public function hasMetadataFor($value)
{
return false;
}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp