templates/Builder/Om/baseObjectMethodMagicCall.php
<?php if ($behaviorCallScript) :?>
/**
* Catches calls to undefined methods.
*
* Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
* Allows to define default __call() behavior if you overwrite __call()
*
* @param string $name
* @param mixed $params
*
* @return array|string
*/
public function __call($name, $params)
{
<?php echo $behaviorCallScript?>
return $this->__parentCall($name, $params);
}
<?php endif?>
/**
* Derived method to catches calls to undefined methods.
*
* Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.).
* Allows to define default __call() behavior if you overwrite __call()
*
* @param string $name
* @param mixed $params
*
* @return array|string
*/
public function __<?php echo ($behaviorCallScript) ? 'parentCall' : 'call'?>($name, $params)
{
if (0 === strpos($name, 'get')) {
$virtualColumn = substr($name, 3);
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
$virtualColumn = lcfirst($virtualColumn);
if ($this->hasVirtualColumn($virtualColumn)) {
return $this->getVirtualColumn($virtualColumn);
}
}
if (0 === strpos($name, 'from')) {
$format = substr($name, 4);
$inputData = $params[0];
$keyType = $params[1] ?? TableMap::TYPE_PHPNAME;
return $this->importFrom($format, $inputData, $keyType);
}
if (0 === strpos($name, 'to')) {
$format = substr($name, 2);
$includeLazyLoadColumns = $params[0] ?? true;
$keyType = $params[1] ?? TableMap::TYPE_PHPNAME;
return $this->exportTo($format, $includeLazyLoadColumns, $keyType);
}
throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name));
}