Destructable.php

Same filename in other branches
  1. 11.x core/modules/system/tests/modules/destructable_test/src/Destructable.php

Namespace

Drupal\destructable_test

File

core/modules/system/tests/modules/destructable_test/src/Destructable.php

View source
<?php

namespace Drupal\destructable_test;

use Drupal\Core\DestructableInterface;
final class Destructable implements DestructableInterface {
    
    /**
     * Semaphore filename.
     *
     * @var string
     */
    protected string $semaphore;
    
    /**
     * Set the destination for the semaphore file.
     *
     * @param string $semaphore
     *   Temporary file to set a semaphore flag.
     */
    public function setSemaphore(string $semaphore) : void {
        $this->semaphore = $semaphore;
    }
    
    /**
     * {@inheritdoc}
     */
    public function destruct() {
        sleep(3);
        file_put_contents($this->semaphore, 'ran');
    }

}

Classes

Title Deprecated Summary
Destructable

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.