Deletes the file referenced by the element.

@param array $element
The element. If set, its value should be a file entity ID.
179260
public static function delete(array $element) {
    if ($element['#value']) {
      $file = File::load($element['#value']);
      $file->delete();

      // Clean up the file system if needed.
      $uri = $file->getFileUri();
      if (file_exists($uri)) {
        \Drupal::service('file_system')->unlink($uri);
      }
    }
  }
600757
public static function Delete( string $file )
   {

      if ( ! \file_exists( $file ) )
      {
         // No deleting required
         return;
      }

      try
      {
         \unlink( $file );
         \clearstatcache();
         if ( ! \file_exists( $file ) )
         {
            // Deleting was successful
            return;
         }
      }
      catch ( \Throwable $ex ) { }

      if ( '\\' === DIRECTORY_SEPARATOR )
      {
         $f = \escapeshellarg( $file );
         try { \exec( "del {$f}" ); }
         catch ( \Throwable $ex )
         {
            throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
         }
         \clearstatcache();
         if ( \file_exists( $file ) )
         {
            throw new IOException(
               $file,
               'Deleting the defined file fails! No known method works.'
            );
         }
         return;
      }

      try { \exec( "unlink {$file}" ); }
      catch ( \Throwable $ex )
      {
         throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
      }

      \clearstatcache();

      if ( \file_exists( $file ) )
      {
         throw new IOException(
            $file,
            'Deleting the defined file fails!'
         );
      }

   }
308752
private function wrap($element) {
        $this->stack[] = $this->data;
        foreach ($element as $k => $v) {
            $this->data[$k] = $v;
        }
    }
917642
public function delete( $file ) {

		$parent = $this->get_file( dirname( $file ) );

		$filename = basename( $file );

		if (
			false === $parent
			|| 'dir' !== $parent->type
			|| false === isset( $parent->contents->$filename )
		) {
			return false;
		}

		unset( $parent->contents->$filename );

		return true;
	}
51591
protected function getFileDescriptor($element)
    {
        $fileDescriptor = $element instanceof FileDescriptor
            ? $element
            : $element->getFile();

        if (!$fileDescriptor instanceof FileDescriptor) {
            throw new \UnexpectedValueException('An element should always have a file associated with it');
        }

        return $fileDescriptor;
    }
1183490
public function remove($element) {
		$index = array_search($element, $this->collection, true);
		if ($index !== null) {
			unset($this->collection[$index]);
		}

		return $this;
	}
434353
public function removeElement($element)
    {
        if (!$this->hasElement($element)) {
            return false;
        }

        $totalCollection = $this->count();
        $key             = $this->indexOf($element);

        unset($this->collections[$key]);

        return $this->count() !== $totalCollection;
    }
1240075
public function deleteFile($file)
    {
        if (!$this->filesystem->has($file)) {
            return;
        }

        $this->filesystem->delete($file);
        $this->cacheManager->remove($file);
    }
29954
protected function writeElement($element): void
    {
        fwrite($this->stream, (string)$element . $this->endline);
    }
231434
public function deleteElement(ListElement $element)
    {
        if (!$this->hasElement($element->getUuid())) {
            throw new ListElementKeyDoesNotExistException('Invalid key '.$element->getUuid()->getUuid());
        }

        unset($this->elements[$element->getUuid()->getUuid()]);
    }
1091060
public function remove($h)
	{
		$e = $this->getRawElement($h);
		if($e == null)
			return false;
		if($e[0] == self::TYPE_FILE)
			$this->removeFile($e[1]);
		unset($this->elements[$h]);
		return true;
	}
267459
public synchronized void removeElement(T element) {
		List<T> origList = ref.get().list;
		boolean isPresent = origList.contains(element);
		if (!isPresent) {
			return;
		}
		
		List<T> newList = new ArrayList<T>(origList);
		newList.remove(element);
		
		swapWithList(newList);
	}
1285058
public function removeListElement( core_kernel_classes_Resource $element)
    {
        $returnValue = (bool) false;

        
        
		if(!is_null($element)){
			$returnValue = $element->delete();
        }
        
        

        return (bool) $returnValue;
    }
578472
public function delete($key)
    {
        $fileKey = $this->getFilenameFromCacheKey($key);

        if (true === \file_exists($fileKey)) {
            $this->removeCacheFile($fileKey);
        }

        $this->deleteChain($key);
    }
399822
public function deleteTemplateEntry($element, $client=1)
	{
		if ($this->baseDb->tableExists('#__extensions'))
		{
			$query = "DELETE FROM `#__extensions` WHERE `type` = 'template' AND `element` = '{$element}' AND `client_id` = '{$client}'";
			$this->baseDb->setQuery($query);
			$this->baseDb->query();

			$this->log(sprintf('Removed extension entry for template "%s"', $element));

			if ($this->baseDb->tableExists('#__template_styles'))
			{
				$query = "DELETE FROM `#__template_styles` WHERE `template` = '{$element}' AND `client_id` = '{$client}'";
				$this->baseDb->setQuery($query);
				$this->baseDb->query();

				$this->log(sprintf('Removed style entry for template "%s"', $element));

				// Now make sure we have an enabled template (don't really care which one it is)
				$query = "SELECT `id` FROM `#__template_styles` WHERE `home` = 1 AND `client_id` = '{$client}'";
				$this->baseDb->setQuery($query);
				if (!$this->baseDb->loadResult())
				{
					$query = "SELECT `id` FROM `#__template_styles` WHERE `client_id` = '{$client}' ORDER BY `id` DESC LIMIT 1";
					$this->baseDb->setQuery($query);
					if ($id = $this->baseDb->loadResult())
					{
						$query = "UPDATE `#__template_styles` SET `home` = 1 WHERE `id` = '{$id}'";
						$this->baseDb->setQuery($query);
						$this->baseDb->query();

						$this->log(sprintf('Setting "home" for template style "%s"', $id));
					}
				}
			}

			return true;
		}

		return false;
	}
72516
public function delete($id)
    {
        $entity = $this->findById($id);
        $entity = $this->beforeDelete($entity);

        $this->getEntityManager()->remove($entity);
        $this->getEntityManager()->flush();

        $this->afterDelete($entity);
    }
965193
protected function _removeFile($file)
    {
        $_file = new File($file);

        if ($_file->exists()) {
            $_file->delete();

            $folder = $_file->folder();
            if (count($folder->find()) === 0) {
                $folder->delete();
            }
            return true;
        }
        return false;
    }