私は現在、Doctrine 2のものを使用しており、ObjectExists.php
やのような検証のためにDoctrineモジュールに着陸しましたNoObjectExists.php
。
私の質問は、ここにある元のコードからです。
/**
* Constructor
*
* @param array $options required keys are `object_repository`, which must be an instance of
* Doctrine\Common\Persistence\ObjectRepository, and `fields`, with either
* a string or an array of strings representing the fields to be matched by the validator.
* @throws \Zend\Validator\Exception\InvalidArgumentException
*/
public function __construct(array $options)
{
if (!isset($options['object_repository']) || !$options['object_repository'] instanceof ObjectRepository) {
if (!array_key_exists('object_repository', $options)) {
$provided = 'nothing';
} else {
if (is_object($options['object_repository'])) {
$provided = get_class($options['object_repository']);
} else {
$provided = getType($options['object_repository']);
}
}
throw new Exception\InvalidArgumentException(sprintf(
'Option "object_repository" is required and must be an instance of'
. ' Doctrine\Common\Persistence\ObjectRepository, %s given',
$provided
));
}
$this->objectRepository = $options['object_repository'];
if (!isset($options['fields'])) {
throw new Exception\InvalidArgumentException(
'Key `fields` must be provided and be a field or a list of fields to be used when searching for'
. ' existing instances'
);
}
$this->fields = $options['fields'];
$this->validateFields();
parent::__construct($options);
}
ここで「必要なキーは、のインスタンスである必要があります」と記載されているという事実を理解できません。$options
object_repository
Doctrine\Common\Persistence\ObjectRepository
はインターフェイスなのでDoctrine\Common\Persistence\ObjectRepository
、そのステートメントをどのようにデコードする必要がありますか?
または、言い換えると、このObjectsExists
クラスのコンストラクターを呼び出してobject_repository
、のインスタンスである必要があるを渡すにはどうすればよいDoctrine\Common\Persistence\ObjectRepository
ですか?
誰かがこれに光を当てることができますか、私はこのことを始めていますので、私の質問に厳しくしないでください。
ありがとう