Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added ClassmapClearTask

  • Loading branch information...
commit 1680c2308ca593b2d68fee79b7ae3878b107ba86 1 parent db6983e
heartsentwined authored
Showing with 78 additions and 0 deletions.
  1. +14 −0 README.md
  2. +64 −0 src/task/ClassmapClearTask.php
14 README.md
View
@@ -49,6 +49,20 @@ Generate a classmap for the directory `foo/library` (and its subdirectories), sa
</project>
```
+## ClassmapClearTask
+
+Clear the classmap file `foo/autoload_classmap.php`, i.e. set it to `return array();`.
+
+```xml
+<project>
+ <target>
+ <includepath classpath="vendor/heartsentwined/phing-task/src/task" />
+ <taskdef name="classmap-clear" classname="ClassmapClearTask" />
+ <classmap-clear file="foo/autoload_classmap.php" />
+ </target>
+</project>
+```
+
## RchownTask
Recursively [chown](http://php.net/manual/en/function.chown.php) the directory `foo/src`, along with all its subdirectories and files, to the user `foouser` and group `foogroup`.
64 src/task/ClassmapClearTask.php
View
@@ -0,0 +1,64 @@
+<?php
+require_once __DIR__ . '/../../../../autoload.php';
+
+use Zend\File\ClassFileLocator;
+
+class ClassmapClearTask extends Task
+{
+ protected $file;
+ protected $failonerror = false;
+
+ /**
+ * classmap file
+ *
+ * @param string $file
+ * @return void
+ */
+ public function setFile($file)
+ {
+ touch($file);
+ $this->file = realpath($file);
+ }
+
+ /**
+ * if error occured, whether build should fail
+ *
+ * @param bool $value
+ * @return void
+ */
+ public function setFailonerror($value)
+ {
+ $this->failonerror = $value;
+ }
+
+ /**
+ * init
+ *
+ * @return void
+ */
+ public function init()
+ {
+ }
+
+ /**
+ * main method
+ *
+ * @return void
+ */
+ public function main()
+ {
+ $this->log(sprintf('Clearing classmap file %s', $this->file));
+
+ // Create a file with the class/file map.
+ // Stupid syntax highlighters make separating < from PHP declaration necessary
+ $content = '<' . "?php\n"
+ . "// Auto-generated by Phing, using ZF2's classmap generator\n"
+ . '// Generation time: ' . date(DATE_RFC2822) . "\n"
+ . 'return array();';
+
+ // Write the contents to disk
+ file_put_contents($this->file, $content);
+
+ $this->log(sprintf('Cleared classmap file at %s', $this->file));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.