-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
900 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# CHANGELOG | ||
|
||
## v1.0.1 | ||
- English translation | ||
- Improved & Documented `ArrayDataLoader` | ||
- Filters are loaded over Dependency Injection | ||
- Batch Actions are defined on the table | ||
- Lots of styling improvements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# Array Data Loader | ||
|
||
The standard data loader is the `DoctrineDataLoader`. It loads data from a database table. | ||
Also when using the full araise framework, mostly the data is stored in a database. | ||
|
||
There are cases where you just need to dispaly a table with data from an array. | ||
For this case the `ArrayDataLoader` is the right choice. | ||
|
||
## Usage | ||
`Controller/DefaultController.php`: | ||
```php | ||
namespace App\Controller; | ||
|
||
use araise\TableBundle\DataLoader\ArrayDataLoader; | ||
use araise\TableBundle\Factory\TableFactory; | ||
use araise\TableBundle\Table\Table; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Faker\Factory; | ||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class DefaultController extends AbstractController | ||
{ | ||
|
||
public function __construct(protected TableFactory $tableFactory) | ||
{ | ||
} | ||
|
||
#[Route('/', name: 'index')] | ||
public function indexAction(): Response | ||
{ | ||
$table = $this->tableFactory->create('project', ArrayDataLoader::class, [ | ||
Table::OPT_DATALOADER_OPTIONS => [ | ||
ArrayDataLoader::OPT_DATA => $this->getTestDataArray(), | ||
], | ||
]); | ||
$table | ||
->addColumn('Name', null, [ | ||
'accessor_path' => '[name]', | ||
]) | ||
->addColumn('Phone', null, [ | ||
'accessor_path' => '[phone]', | ||
]) | ||
->addColumn('Firma', null, [ | ||
'accessor_path' => '[company]', | ||
]) | ||
; | ||
|
||
return $this->render('index.html.twig', [ | ||
'table' => $table, | ||
]); | ||
} | ||
|
||
protected function getTestDataArray(int $many = 200): ArrayCollection | ||
{ | ||
$faker = Factory::create(); | ||
$faker->seed(1234); // to always get the same data | ||
$col = new ArrayCollection(); | ||
for ($i = 1; $i <= $many; $i++) { | ||
$col->add([ | ||
'name' => $faker->name(), | ||
'phone' => $faker->phoneNumber(), | ||
'company' => $faker->company(), | ||
]); | ||
} | ||
return $col; | ||
} | ||
|
||
} | ||
``` | ||
`templates/index.html.twig`: | ||
```twig | ||
{% extends 'base.html.twig' %} | ||
{% block body %} | ||
{{ araise_table_render(table) }} | ||
{% endblock %} | ||
``` | ||
|
||
You could also use `araise_table_only_render` in your twig template, this will skip the pagination and filters. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.