PluginProbe
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager / 0.0.3
Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager v0.0.3
0.0.11 0.0.10 0.0.9 0.0.8 0.0.7 0.0.6 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5
cookiez / modules / cookie / database / cookie-entry.php

cookie-entry.php in Cookie Consent – GDPR & CCPA Cookie Banner & Consent Manager 0.0.3, at modules/cookie/database/cookie-entry.php

60 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Cookiez\Modules\Cookie\Database;
4
5 use Cookiez\Classes\Database\Entry;
6 use Cookiez\Modules\Cookie\Classes\Dto\Cookie_DTO;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 class Cookie_Entry extends Entry {
13 protected static function get_helper_class(): string {
14 return Cookie_Table::class;
15 }
16
17 public static function find_all( array $where = [], ?int $limit = null, ?int $offset = null ): array {
18 if ( empty( $where ) ) {
19 $where = '1';
20 }
21
22 return (array) Cookie_Table::select(
23 '*',
24 $where,
25 $limit,
26 $offset,
27 '',
28 [ Cookie_Table::NAME => 'ASC' ]
29 );
30 }
31
32 public static function find_by_name_domain( string $name, string $domain ): ?Cookie_Entry {
33 $result = Cookie_Table::first(
34 '*',
35 [
36 Cookie_Table::NAME => $name,
37 Cookie_Table::DOMAIN => $domain,
38 ]
39 );
40
41 if ( ! $result ) {
42 return null;
43 }
44
45 return new self( [ 'data' => $result ] );
46 }
47
48 public static function insert_one( Cookie_DTO $dto ): Cookie_Entry {
49 $entry = new self();
50
51 foreach ( $dto->to_entry() as $key => $value ) {
52 $entry->set( $key, $value );
53 }
54
55 $entry->create();
56
57 return $entry;
58 }
59 }
60