/** * Apply adapters registered for the component * @param C_Component $component * @return C_Component */ function &apply_adapters(C_Component &$component) { // Iterate through each adapted interface. If the component implements // the interface, then apply the adapters foreach ($this->_adapters as $interface => $contexts) { if ($component->implements_interface($interface)) { // Determine what context apply to the current component $applied_contexts = array('all'); if ($component->context) { $applied_contexts[] = $component->context; $applied_contexts = $this->_flatten_array($applied_contexts); } // Iterate through each of the components contexts and apply the // registered adapters foreach ($applied_contexts as $context) { if (isset($contexts[$context])) { foreach ($contexts[$context] as $adapter) { $component->add_mixin($adapter, TRUE); } } } } } return $component; }