/*!
Removes content class and all data associated with it.
\static
437929
static function remove( $classID )
    {
        $contentClass = eZContentClass::fetch( $classID );

        if ( $contentClass == null or !$contentClass->isRemovable() )
            return false;

        // Remove all objects
        $contentObjects = eZContentObject::fetchSameClassList( $classID );
        foreach ( $contentObjects as $contentObject )
        {
            eZContentObjectOperations::remove( $contentObject->attribute( 'id' ) );
        }

        if ( count( $contentObjects ) == 0 )
            eZContentObject::expireAllViewCache();

        eZContentClassClassGroup::removeClassMembers( $classID, 0 );
        eZContentClassClassGroup::removeClassMembers( $classID, 1 );

        // Fetch real version and remove it
        $contentClass->remove( true );

        // Fetch temp version and remove it
        $tempDeleteClass = eZContentClass::fetch( $classID, true, 1 );
        if ( $tempDeleteClass != null )
            $tempDeleteClass->remove( true, 1 );

        return true;
    }
487405
function removeContentObject( $params )
    {
        $object = $this->contentObjectByName( $params );
        if( is_object( $object ) )
        {
            $object->purge();
        }
        else
        {
            eZDebug::writeWarning( "Object with name '" . $params['name'] . "' doesn't exist", __METHOD__ );
        }
    }
185988
public function clear() {
		$i=0;
		if ($glob=@glob($this->f3->get('ASSETS.public_path').'*'))
			foreach ($glob as $file)
				if (preg_match('/.+?\.(js|css)/i',basename($file))) {
					$i++;
					@unlink($file);
				}
		return $i;
	}
15859
public static function remove_class_content($filePath, $cutOffDepth = 1)
    {

        // Use PHP's built in method to strip comments and whitespace
        $contents = php_strip_whitespace($filePath);

        if (!trim($contents)) {
            return $contents;
        }

        if (!preg_match('/\b(?:class|interface|trait)/i', $contents)) {
            return '';
        }

        // tokenize the file contents
        $tokens = token_get_all($contents);
        $cleanContents = '';
        $depth = 0;
        $startCounting = false;
        // iterate over all the tokens and only store the tokens that are outside $cutOffDepth
        foreach ($tokens as $token) {
            // only store the string literal of the token, that's all we need
            if (!is_array($token)) {
                $token = [
                    T_STRING,
                    $token,
                    null
                ];
            }

            // only count if we see a class/interface/trait keyword
            if (!$startCounting && in_array($token[0], [T_CLASS, T_INTERFACE, T_TRAIT])) {
                $startCounting = true;
            }

            // use curly braces as a sign of depth
            if ($token[1] === '{') {
                if ($depth < $cutOffDepth) {
                    $cleanContents .= $token[1];
                }
                if ($startCounting) {
                    ++$depth;
                }
            } elseif ($token[1] === '}') {
                if ($startCounting) {
                    --$depth;

                    // stop counting if we've just come out of the
                    // class/interface/trait declaration
                    if ($depth <= 0) {
                        $startCounting = false;
                    }
                }
                if ($depth < $cutOffDepth) {
                    $cleanContents .= $token[1];
                }
            } elseif ($depth < $cutOffDepth) {
                $cleanContents .= $token[1];
            }
        }

        // return cleaned class
        return trim($cleanContents);
    }
709984
public void removeAll()
	{
		for (UIComponent component : content.components)
			component.setParent(null);
		content.components.clear();
		onContentUpdate();
	}
789678
static function removeTemporary()
    {
        $version = eZContentClass::VERSION_STATUS_TEMPORARY;
        $temporaryClasses = eZContentClass::fetchList( $version, true );
        $db = eZDB::instance();
        $db->begin();
        foreach ( $temporaryClasses as $class )
        {
            $class->remove( true, $version );
        }
        eZPersistentObject::removeObject( eZContentClassAttribute::definition(),
                                          array( 'version' => $version ) );

        $db->commit();
    }
517258
public function removeContent(\Coral\ContentBundle\Entity\Content $contents)
    {
        $this->contents->removeElement($contents);
    }
814779
function removeClassAttribute( $params )
    {
        $contentClassID = $params['class_id'];
        $classAttributeIdentifier = $params['attribute_identifier'];

        // get attributes of 'temporary' version as well
        $classAttributeList = eZContentClassAttribute::fetchFilteredList( array( 'contentclass_id' => $contentClassID,
                                                                                  'identifier' => $classAttributeIdentifier ),
                                                                           true );

        $validation = array();
        foreach( $classAttributeList as $classAttribute )
        {
            $dataType = $classAttribute->dataType();
            if( $dataType->isClassAttributeRemovable( $classAttribute ) )
            {
                $objectAttributes = eZContentObjectAttribute::fetchSameClassAttributeIDList( $classAttribute->attribute( 'id' ) );
                foreach( $objectAttributes as $objectAttribute )
                {
                    $objectAttributeID = $objectAttribute->attribute( 'id' );
                    $objectAttribute->removeThis( $objectAttributeID );
                }

                $classAttribute->removeThis();
            }
            else
            {
                $removeInfo = $dataType->classAttributeRemovableInformation( $classAttribute );
                if( $removeInfo === false )
                    $removeInfo = "Unknow reason";

                $validation[] = array( 'id' => $classAttribute->attribute( 'id' ),
                                       'identifier' => $classAttribute->attribute( 'identifier' ),
                                       'reason' => $removeInfo );
            }
        }

        if( count( $validation ) > 0 )
        {
            $this->reportError( $validation, 'eZSiteInstaller::removeClassAttribute: Unable to remove eZClassAttribute(s)' );
        }

    }
300187
static function clearClassID( $cacheItem )
    {
        $cachePath = eZSys::cacheDirectory();

        $fileHandler = eZClusterFileHandler::instance();
        $fileHandler->fileDelete( $cachePath, 'classidentifiers_' );
        $fileHandler->fileDelete( $cachePath, 'classattributeidentifiers_' );
        eZContentClass::expireCache();
        ezpEvent::getInstance()->notify( 'content/class/cache/all' );
    }
391078
public function delete_content() {
        global $CFG, $DB;

        blocks_delete_all_for_context($this->_id);
        filter_delete_all_for_context($this->_id);

        require_once($CFG->dirroot . '/comment/lib.php');
        comment::delete_comments(array('contextid'=>$this->_id));

        require_once($CFG->dirroot.'/rating/lib.php');
        $delopt = new stdclass();
        $delopt->contextid = $this->_id;
        $rm = new rating_manager();
        $rm->delete_ratings($delopt);

        // delete all files attached to this context
        $fs = get_file_storage();
        $fs->delete_area_files($this->_id);

        // Delete all repository instances attached to this context.
        require_once($CFG->dirroot . '/repository/lib.php');
        repository::delete_all_for_context($this->_id);

        // delete all advanced grading data attached to this context
        require_once($CFG->dirroot.'/grade/grading/lib.php');
        grading_manager::delete_all_for_context($this->_id);

        // now delete stuff from role related tables, role_unassign_all
        // and unenrol should be called earlier to do proper cleanup
        $DB->delete_records('role_assignments', array('contextid'=>$this->_id));
        $DB->delete_records('role_names', array('contextid'=>$this->_id));
        $this->delete_capabilities();
    }
739978
public function clear()
    {
        if ($this->childNodes->length > 0) {
            foreach ($this->childNodes as $childNode) {
                $this->removeChild($childNode);
            }
        }

        $this->textContent = null;
    }
1109407
public function clear()
    {
        if (!($this->_content instanceof ContentSet)) {
            throw new ClassContentException(
                sprintf('Can not clear an content %s.', get_class($this)),
                ClassContentException::UNKNOWN_ERROR
            );
        }

        $this->_data = array();
        $this->_index = 0;
    }
290804
static function cleanup()
    {
        $searchEngine = eZSearch::getEngine();

        if ( $searchEngine instanceof ezpSearchEngine && method_exists( $searchEngine, 'cleanup' ) )
        {
            $searchEngine->cleanup();
        }
    }
163906
public function removeTmpFiles()
	{
		if (file_exists($this->getHTMLPath()))
		{
			@unlink($this->getHTMLPath());
		}
		if (file_exists($this->getPDFPath()))
		{
			@unlink($this->getPDFPath());
		}
	}
1191795
public static function clean($filename = null)
    {
        static::filename($filename);

        static::$description   =
        static::$keywords      =
        static::$title         =
        static::$jsTextOnReady = '';
        static::$css           =
        static::$js            =
        static::$jsText        =
        static::$jsMgr         = [];
    }
1187443
public function filterContent() {
		$removals = $this->parseItemsToRemove();

		// Bail out early if nothing to do
		if ( \array_reduce( $removals,
			function ( $carry, $item ) {
				return $carry && !$item;
			},
			true
		) ) {
			return [];
		}

		$doc = $this->getDoc();

		// Remove tags

		// You can't remove DOMNodes from a DOMNodeList as you're iterating
		// over them in a foreach loop. It will seemingly leave the internal
		// iterator on the foreach out of wack and results will be quite
		// strange. Though, making a queue of items to remove seems to work.
		$domElemsToRemove = [];
		foreach ( $removals['TAG'] as $tagToRemove ) {
			$tagToRemoveNodes = $doc->getElementsByTagName( $tagToRemove );
			foreach ( $tagToRemoveNodes as $tagToRemoveNode ) {
				if ( $tagToRemoveNode ) {
					$domElemsToRemove[] = $tagToRemoveNode;
				}
			}
		}
		$removed = $this->removeElements( $domElemsToRemove );

		// Elements with named IDs
		$domElemsToRemove = [];
		foreach ( $removals['ID'] as $itemToRemove ) {
			$itemToRemoveNode = $doc->getElementById( $itemToRemove );
			if ( $itemToRemoveNode ) {
				$domElemsToRemove[] = $itemToRemoveNode;
			}
		}
		$removed = array_merge( $removed, $this->removeElements( $domElemsToRemove ) );

		// CSS Classes
		$domElemsToRemove = [];
		$xpath = new \DOMXPath( $doc );
		foreach ( $removals['CLASS'] as $classToRemove ) {
			$elements = $xpath->query( '//*[contains(@class, "' . $classToRemove . '")]' );

			/** @var $element \DOMElement */
			foreach ( $elements as $element ) {
				$classes = $element->getAttribute( 'class' );
				if ( \preg_match( "/\b$classToRemove\b/", $classes ) && $element->parentNode ) {
					$domElemsToRemove[] = $element;
				}
			}
		}
		$removed = \array_merge( $removed, $this->removeElements( $domElemsToRemove ) );

		// Tags with CSS Classes
		foreach ( $removals['TAG_CLASS'] as $classToRemove ) {
			$parts = explode( '.', $classToRemove );

			$elements = $xpath->query(
				'//' . $parts[0] . '[@class="' . $parts[1] . '"]'
			);
			$removed = array_merge( $removed, $this->removeElements( $elements ) );
		}

		return $removed;
	}
769528
function removeThis( $quiet = false )
    {
        $dataType = $this->dataType();
        if ( $dataType->isClassAttributeRemovable( $this ) )
        {
            self::expireCache( $this->ID, $this->attribute( 'contentclass_id' ) );

            $db = eZDB::instance();
            $db->begin();
            $dataType->deleteStoredClassAttribute( $this, $this->Version );
            $this->remove();
            $db->commit();
            return true;
        }
        else
        {
            if ( !$quiet )
            {
                eZDebug::writeError( 'Datatype [' . $dataType->attribute( 'name' ) . '] can not be deleted to avoid system crash' );
            }
            return false;
        }
    }