void AutoloadHandler::removeHandler(CVarRef handler) { SmartCufIterPtr cufIter = nullptr; if (!vm_decode_function_cufiter(handler, cufIter)) { return; } // Use find_if instead of remove_if since we know there can only be one match // in the vector. auto const& compareBundles = CompareBundles(cufIter.get()); m_handlers.erase( std::find_if(m_handlers.begin(), m_handlers.end(), compareBundles)); }
bool AutoloadHandler::addHandler(const Variant& handler, bool prepend) { SmartCufIterPtr cufIter = nullptr; if (!vm_decode_function_cufiter(handler, cufIter)) { return false; } m_spl_stack_inited = true; // Zend doesn't modify the order of the list if the handler is already // registered. auto const& compareBundles = CompareBundles(cufIter.get()); if (std::find_if(m_handlers.begin(), m_handlers.end(), compareBundles) != m_handlers.end()) { return true; } if (!prepend) { m_handlers.emplace_back(handler, cufIter); } else { m_handlers.emplace_front(handler, cufIter); } return true; }