PHP code example of grigorygraborenko / recursive-admin
1. Go to this page and download the library: Download grigorygraborenko/recursive-admin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grigorygraborenko / recursive-admin example snippets
$bundles = [
...
new Grigorygraborenko\RecursiveAdmin\RecursiveAdminBundle(),
use Grigorygraborenko\RecursiveAdmin\Annotations\Admin;
/**
* @ORM\Entity
* @Admin(entity=["ROLE_ADMIN", "ROLE_TESTER"], sortBy="name", priority=1000, label="Result of Test")
*/
class TestResult {
/**
* @ORM\Column(type="string")
* @Admin(read="ROLE_ADMIN", priority=10, label="Test Name")
*/
protected $name;
public function SERVICE_FUNCTION($container, $admin) {
$user_input = array(
"api" => array(
"type" => "select"
,"label" => "Which API?"
,"choices" => array(
array("label" => "Internal", "value" => "int_01")
,array("label" => "External", "value" => "ext_02")
,array("label" => "All of them", "value" => "*")
)
)
,"num_tests" => array(
"type" => "integer"
,"label" => "How many times should the tests run?"
,"default" => 1
,"omatic tests for each API"
,"permission" => "ROLE_SUPER_ADMIN"
,"input" => $super_user_input
)
);
}
public function runTests($container, $admin, $input) {
...
if($some_error) {
return "Tests had an error of some sort";
}
...
return array("report" => "Everything went well");
}
$user_input = array(
"test_name" => array("type" => "string", "label" => "Name of New Test", " => true, "lines" => 4) // lines will enable textarea with N rows
,"test_quantity" => array("type" => "integer", "label" => "How many times it should run", "default" => 1)
,"test_fraction" => array("type" => "decimal", "label" => "Fraction of acceptable errors", "bel" => "Both internal & external", "value" => "hybrid")
))
,"test_rerun" => array("type" => "select", "label" => "Re-run in case of failure?", "default" => "false", "choices" => array(
array("label" => "No", "value" => "false")
,array("label" => "Yes", "value" => "true", "input" => array(
"test_num_reruns" => array("type" => "integer", "label" => "How many times it should attempt to re-run", "default" => 10)
,"test_justification" => array("type" => "string", "label" => "Why should this test re-run?", "default" => "Because why not.")
))
))
,"test_user" => array("type" => "entity", "label" => "A user responsible for this test", "entity" => 'AppBundle\Entity\User')
,"test_dependencies" => array("type" => "multientity", "label" => "A list of tests that must run first", , "entity" => 'AppBundle\Entity\TestSpec')
,"test_error_descriptions" => array("type" => "array", "label" => "A list of descriptions for error codes", "input" => array(
"code" => array("type" => "integer", "label" => "Error code", "
// the callback function will get something like this back:
$input_result = array(
"test_name" => "Division by zero"
,"test_quantity" => 3
,"test_fraction" => 0.2
,"test_type" => "internal"
,"test_rerun" => "true" // if this was "false", the array would not have the next two entries
,"test_num_reruns" => 126 // only appears if "test_rerun" was "true"
,"test_justification" => "Just in case that zero wasn't really zero, but a really small number." // only appears if "test_rerun" was "true"
,"test_user" => "ID_43tgf43mn9j38er23" // Not an object, but an ID
,"test_dependencies" => array("ID_3hj767jfgfdg", "ID_rthg54trhytj4t") // Not an array of objects, but ID's
,"test_error_descriptions" => array(
array("code" => 12, "description" => "Something mysterious went wrong")
,array("code" => 46, "description" => "Negative zero encountered")
,array("code" => 1, "description" => "There was an error detected in the error detection subroutines")
)
,"test_file" => [OBJECT]
);
// either this...
,"test_rerun" => array("value" => "true", "input" => array(
"test_num_reruns" => 126
,"test_justification" => "Just in case that zero wasn't really zero, but a really small number."
)
// ...or this
,"test_rerun" => array("value" => "false", "input" => array()
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.