PHP code example of jadob / objectable

1. Go to this page and download the library: Download jadob/objectable 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/ */

    

jadob / objectable example snippets


 

use Jadob\Objectable\Annotation as Objectable;

/**
 * @Objectable\Row()
 * @Objectable\ActionField(name="edit", label="Edit User", path="/user/edit", property="id")
 * @Objectable\ActionField(name="remove", label="Remove User", path="/user/remove", property="id")
 */
 class User {/* ... */}

 

use Jadob\Objectable\Annotation as Objectable;

class Person {

    /**
     * @Objectable\Header(title="ID", order=1) 
     * @var int
     */
    public $id;
    
    /**
     * @Objectable\Header(title="Last Name", order=3) 
     * @var string
     */
    public $lastName;
    
    /**
      * @Objectable\Header(title="First Name", order=2) 
      * @var string
      */
    public $firstName;

}




class UpperCaseTransformer implements \Jadob\Objectable\Transformer\HeaderTransformerInterface {
    
    /**
     * @param string $title
     * @param string $className
     * @param string $propertyName
     * @return string
     */
    public function transform(string $title, string $className, string $propertyName): string
    {
        return \strtoupper($title);
    }
}


/** @var \Jadob\Objectable\Objectable $objectable */
$objectable->setHeaderTransformer(new UpperCaseTransformer());