File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
src/PhpPresentation/Slide Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -118,9 +118,25 @@ public function getShapeCollection()
118
118
}
119
119
120
120
/**
121
- * Get collection of shapes.
121
+ * Search into collection of shapes for a name (eventually filtered by type ex: RichText)
122
122
*
123
- * @param array<int, AbstractShape>|ArrayObject<int, AbstractShape> $shapeCollection
123
+ * @param string $name The name to find into the shape collection
124
+ * @param PhpOffice\PhpPresentation\Shape\RichText | PhpOffice\PhpPresentation\Shape\... $type Type of the class
125
+ * @return \ArrayObject|\PhpOffice\PhpPresentation\AbstractShape[]
126
+ */
127
+ public function searchShapeByName (string $ name , ?string $ type =null )
128
+ {
129
+ if (isset ($ this ->shapeCollection )) {
130
+ foreach ($ this ->shapeCollection as $ shape ) {
131
+ if ($ shape ->getName () == $ name ) {
132
+ if (!isset ($ type ) || get_class ($ shape ) == $ type ) {
133
+ return $ shape ;
134
+ }}}}
135
+ return null ;
136
+ }
137
+
138
+ /**
139
+ * Get collection of shapes
124
140
*
125
141
* @return AbstractSlide
126
142
*/
You can’t perform that action at this time.
0 commit comments