Skip to content
Snippets Groups Projects
Commit f640bd0b authored by jaapjansma's avatar jaapjansma
Browse files

Refactored the factory.

parent 608089a9
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
* Fixed caching issues.
* Add Recurring Contribution as datasource
* Added Field Output Handler for Is Active fields based on dates (start date and end date).
* Refactored the factory.
# Version 1.2.0
......
This diff is collapsed.
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\DataProcessor\Factory;
class Definition {
protected $class;
protected $arguments = null;
/**
* Definition constructor.
*
* @param String $class
* @param array $arguments
* Optional
*/
public function __construct($class, $arguments=null) {
$this->class = $class;
if (is_array($arguments)) {
$this->arguments = $arguments;
}
}
/**
* @return object
* @throws \ReflectionException
*/
public function get() {
$reflectionClass = new \ReflectionClass($this->class);
if ($reflectionClass->getConstructor()) {
return $reflectionClass->newInstance($this->arguments);
} else {
return $reflectionClass->newInstanceWithoutConstructor();
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment