Completed
Branch gql-bulk-delete-prices (c5a763)
by
unknown
51:54 queued 42:20
created
core/domain/services/graphql/mutators/BulkEntityDelete.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -18,76 +18,76 @@
 block discarded – undo
18 18
 
19 19
 class BulkEntityDelete extends EntityMutator
20 20
 {
21
-    /**
22
-     * Defines the mutation data modification closure.
23
-     *
24
-     * @return callable
25
-     */
26
-    public static function mutateAndGetPayload()
27
-    {
28
-        /**
29
-         * Updates an entity.
30
-         *
31
-         * @param array       $input   The input for the mutation
32
-         * @param AppContext  $context The AppContext passed down to all resolvers
33
-         * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
34
-         * @return array
35
-         * @throws UserError
36
-         * @throws ReflectionException
37
-         * @throws InvalidArgumentException
38
-         * @throws InvalidInterfaceException
39
-         * @throws InvalidDataTypeException
40
-         * @throws EE_Error
41
-         */
42
-        return static function ($input, AppContext $context, ResolveInfo $info) {
43
-            /**
44
-             * Stop now if a user isn't allowed to delete.
45
-             */
46
-            if (! current_user_can('ee_delete_events')) {
47
-                throw new UserError(
48
-                    esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
49
-                );
50
-            }
21
+	/**
22
+	 * Defines the mutation data modification closure.
23
+	 *
24
+	 * @return callable
25
+	 */
26
+	public static function mutateAndGetPayload()
27
+	{
28
+		/**
29
+		 * Updates an entity.
30
+		 *
31
+		 * @param array       $input   The input for the mutation
32
+		 * @param AppContext  $context The AppContext passed down to all resolvers
33
+		 * @param ResolveInfo $info    The ResolveInfo passed down to all resolvers
34
+		 * @return array
35
+		 * @throws UserError
36
+		 * @throws ReflectionException
37
+		 * @throws InvalidArgumentException
38
+		 * @throws InvalidInterfaceException
39
+		 * @throws InvalidDataTypeException
40
+		 * @throws EE_Error
41
+		 */
42
+		return static function ($input, AppContext $context, ResolveInfo $info) {
43
+			/**
44
+			 * Stop now if a user isn't allowed to delete.
45
+			 */
46
+			if (! current_user_can('ee_delete_events')) {
47
+				throw new UserError(
48
+					esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
49
+				);
50
+			}
51 51
 
52
-            $details = EntityReorder::prepareEntityDetailsFromInput($input);
52
+			$details = EntityReorder::prepareEntityDetailsFromInput($input);
53 53
 
54
-            $deletePermanently = ! empty($input['deletePermanently']);
54
+			$deletePermanently = ! empty($input['deletePermanently']);
55 55
 
56
-            $deletionMethod = __NAMESPACE__;
57
-            // if it's for datetimes.
58
-            if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
59
-                $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
60
-            } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
61
-                $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
62
-            } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
63
-                $deletionMethod .= '\PriceDelete::deletePriceAndRelations';
64
-            } else {
65
-                throw new UserError(
66
-                    esc_html__(
67
-                        'A valid data model could not be obtained. Did you supply a valid entity type?',
68
-                        'event_espresso'
69
-                    )
70
-                );
71
-            }
56
+			$deletionMethod = __NAMESPACE__;
57
+			// if it's for datetimes.
58
+			if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
59
+				$deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
60
+			} elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
61
+				$deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
62
+			} elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
63
+				$deletionMethod .= '\PriceDelete::deletePriceAndRelations';
64
+			} else {
65
+				throw new UserError(
66
+					esc_html__(
67
+						'A valid data model could not be obtained. Did you supply a valid entity type?',
68
+						'event_espresso'
69
+					)
70
+				);
71
+			}
72 72
 
73
-            $deleted = [];
74
-            $failed  = [];
73
+			$deleted = [];
74
+			$failed  = [];
75 75
 
76
-            foreach ($details['entityDbids'] as $key => $entityDbid) {
77
-                $guid = $details['entityGuids'][ $key ];
78
-                $entity = $details['entities'][ $entityDbid ];
79
-                try {
80
-                    $result = $deletionMethod($entity);
81
-                    EntityMutator::validateResults($result);
82
-                    // we are here it means the deletion was successful.
83
-                    $deleted[] = $guid;
84
-                } catch (Exception $e) {
85
-                    // sorry mate, couldn't help you :(
86
-                    $failed[] = $guid;
87
-                }
88
-            }
76
+			foreach ($details['entityDbids'] as $key => $entityDbid) {
77
+				$guid = $details['entityGuids'][ $key ];
78
+				$entity = $details['entities'][ $entityDbid ];
79
+				try {
80
+					$result = $deletionMethod($entity);
81
+					EntityMutator::validateResults($result);
82
+					// we are here it means the deletion was successful.
83
+					$deleted[] = $guid;
84
+				} catch (Exception $e) {
85
+					// sorry mate, couldn't help you :(
86
+					$failed[] = $guid;
87
+				}
88
+			}
89 89
 
90
-            return compact('deleted', 'failed');
91
-        };
92
-    }
90
+			return compact('deleted', 'failed');
91
+		};
92
+	}
93 93
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
          * @throws InvalidDataTypeException
40 40
          * @throws EE_Error
41 41
          */
42
-        return static function ($input, AppContext $context, ResolveInfo $info) {
42
+        return static function($input, AppContext $context, ResolveInfo $info) {
43 43
             /**
44 44
              * Stop now if a user isn't allowed to delete.
45 45
              */
46
-            if (! current_user_can('ee_delete_events')) {
46
+            if ( ! current_user_can('ee_delete_events')) {
47 47
                 throw new UserError(
48 48
                     esc_html__('Sorry, you do not have the required permissions to delete entities', 'event_espresso')
49 49
                 );
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
             $deletionMethod = __NAMESPACE__;
57 57
             // if it's for datetimes.
58 58
             if ($details['entityType'] === EEM_Datetime::instance()->item_name()) {
59
-                $deletionMethod .= '\DatetimeDelete::' . ($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
59
+                $deletionMethod .= '\DatetimeDelete::'.($deletePermanently ? 'deleteDatetimeAndRelations' : 'trashDatetimeAndRelations');
60 60
             } elseif ($details['entityType'] === EEM_Ticket::instance()->item_name()) {
61
-                $deletionMethod .= '\TicketDelete::' . ($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
61
+                $deletionMethod .= '\TicketDelete::'.($deletePermanently ? 'deleteTicketAndRelations' : 'trashTicket');
62 62
             } elseif ($details['entityType'] === EEM_Price::instance()->item_name()) {
63 63
                 $deletionMethod .= '\PriceDelete::deletePriceAndRelations';
64 64
             } else {
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
             $failed  = [];
75 75
 
76 76
             foreach ($details['entityDbids'] as $key => $entityDbid) {
77
-                $guid = $details['entityGuids'][ $key ];
78
-                $entity = $details['entities'][ $entityDbid ];
77
+                $guid = $details['entityGuids'][$key];
78
+                $entity = $details['entities'][$entityDbid];
79 79
                 try {
80 80
                     $result = $deletionMethod($entity);
81 81
                     EntityMutator::validateResults($result);
Please login to merge, or discard this patch.
core/domain/services/graphql/enums/ModelNameEnum.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -18,33 +18,33 @@
 block discarded – undo
18 18
 class ModelNameEnum extends EnumBase
19 19
 {
20 20
 
21
-    /**
22
-     * ModelNameEnum constructor.
23
-     */
24
-    public function __construct()
25
-    {
26
-        $this->setName($this->namespace . 'ModelNameEnum');
27
-        $this->setDescription(esc_html__('Entity model name', 'event_espresso'));
28
-        parent::__construct();
29
-    }
21
+	/**
22
+	 * ModelNameEnum constructor.
23
+	 */
24
+	public function __construct()
25
+	{
26
+		$this->setName($this->namespace . 'ModelNameEnum');
27
+		$this->setDescription(esc_html__('Entity model name', 'event_espresso'));
28
+		parent::__construct();
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @return array
34
-     * @since $VID:$
35
-     */
36
-    protected function getValues()
37
-    {
38
-        return [
39
-            'DATETIME' => [
40
-                'value' => EEM_Datetime::instance()->item_name(),
41
-            ],
42
-            'TICKET'   => [
43
-                'value' => EEM_Ticket::instance()->item_name(),
44
-            ],
45
-            'PRICE'    => [
46
-                'value' => EEM_Price::instance()->item_name(),
47
-            ],
48
-        ];
49
-    }
32
+	/**
33
+	 * @return array
34
+	 * @since $VID:$
35
+	 */
36
+	protected function getValues()
37
+	{
38
+		return [
39
+			'DATETIME' => [
40
+				'value' => EEM_Datetime::instance()->item_name(),
41
+			],
42
+			'TICKET'   => [
43
+				'value' => EEM_Ticket::instance()->item_name(),
44
+			],
45
+			'PRICE'    => [
46
+				'value' => EEM_Price::instance()->item_name(),
47
+			],
48
+		];
49
+	}
50 50
 }
Please login to merge, or discard this patch.