FOF30\Model\DataModel::removeBehaviour PHP Method

removeBehaviour() public method

Removes a behaviour by its name. It will search the following classes, in this order: \component_namespace\Model\modelName\Behaviour\behaviourName \component_namespace\Model\DataModel\Behaviour\behaviourName \FOF30\Model\DataModel\Behaviour\behaviourName where: component_namespace is the namespace of the component as defined in the container modelName is the model's name, first character uppercase, e.g. Baz behaviourName is the $behaviour parameter, first character uppercase, e.g. Something
public removeBehaviour ( string $behaviour )
$behaviour string The behaviour's name
    public function removeBehaviour($behaviour)
    {
        $prefixes = array($this->container->getNamespacePrefix() . 'Model\\Behaviour\\' . ucfirst($this->getName()), $this->container->getNamespacePrefix() . 'Model\\Behaviour', '\\FOF30\\Model\\DataModel\\Behaviour');
        foreach ($prefixes as $prefix) {
            $className = ltrim($prefix . '\\' . ucfirst($behaviour), '\\');
            $observer = $this->behavioursDispatcher->getObserverByClass($className);
            if (is_null($observer)) {
                continue;
            }
            $this->behavioursDispatcher->detach($observer);
            return $this;
        }
        return $this;
    }