*/
public function getObjectData(IFormDocument $document, IStorableObject $object) {
$data = $object->getData();
- $objectId = $object->{$object::getDatabaseTableIndexName()};
foreach ($this->processors as $processor) {
- $data = $processor->processObjectData($document, $data, $objectId);
+ $data = $processor->processObjectData($document, $data, $object);
if (!is_array($data)) {
if ($processor instanceof CustomFormDataProcessor) {
<?php
namespace wcf\system\form\builder\data\processor;
+use wcf\data\IStorableObject;
use wcf\system\form\builder\IFormDocument;
/**
/**
* @inheritDoc
*/
- public function processObjectData(IFormDocument $document, array $data, $objectId = null) {
+ public function processObjectData(IFormDocument $document, array $data, IStorableObject $object) {
return $data;
}
}
<?php
namespace wcf\system\form\builder\data\processor;
+use wcf\data\IStorableObject;
use wcf\system\form\builder\IFormDocument;
/**
($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected."
);
}
+
if (!$parameters[1]->isArray()) {
throw new \InvalidArgumentException("The form data processor function's second parameter must be an array.");
}
($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected."
);
}
+
if (!$parameters[1]->isArray()) {
throw new \InvalidArgumentException("The object data processor function's second parameter must be an array.");
}
+ $parameterClass = $parameters[2]->getClass();
+ if ($parameterClass === null || $parameterClass->getName() !== IStorableObject::class) {
+ throw new \InvalidArgumentException("The object data processor function's third parameter must be an instance of '" . IStorableObject::class . "', instead " . ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected.");
+ }
+
$this->objectDataProcessor = $objectDataProcessor;
}
}
/**
* @inheritDoc
*/
- public function processObjectData(IFormDocument $document, array $data, $objectId = null) {
+ public function processObjectData(IFormDocument $document, array $data, IStorableObject $object) {
if ($this->objectDataProcessor === null) {
- return parent::processObjectData($document, $data, $objectId);
+ return parent::processObjectData($document, $data, $object);
}
- $data = call_user_func($this->objectDataProcessor, $document, $data, $objectId);
+ $data = call_user_func($this->objectDataProcessor, $document, $data, $object);
if (!is_array($data)) {
throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array.");
<?php
namespace wcf\system\form\builder\data\processor;
+use wcf\data\IStorableObject;
use wcf\system\form\builder\IFormDocument;
/**
*
* @param IFormDocument $document documents whose field values will be set using the processed data
* @param array $data data before processing
- * @param null|integer $objectId id of the object the data belongs to
+ * @param IStorableObject $object object the data belongs to
* @return array data after processing
*/
- public function processObjectData(IFormDocument $document, array $data, $objectId = null);
+ public function processObjectData(IFormDocument $document, array $data, IStorableObject $object);
}